• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2049
  • Last Modified:

Keyboard interrupt

Hi guys!
I need to modify the keyboard interrupt routine of the kernel to create a special command located at this level that shutdown the system.

Well, resuming I need:
1 - Discover what's the file to modify, I think the file is "keyboard.c" but the modifications that I do in this file don't take any effects;
2 - Discover what is the kernel functions to shutdown the system, I try this functions but they not work (kernel_hatl(), unlock_kernel(), do_exit(0))

Thanks for all.
0
zezons
Asked:
zezons
  • 3
  • 2
1 Solution
 
omarfaridCommented:
Hi,

Since you are using linux, you nay use bash key binding feature. Bash reads .inputrc file upon starting, where you can defile keyboard keys binding. The .inputrc file should be in the user home dir.

bash will read the .inputrc from the home directory of the user, where you can put user specific key bindings.

In .inputrc file you may include a system wide inputrc file where you put global key bindings. This can be done by adding the line below to each user .inputrc :

$include      /etc/inputrc

(the $ is must)

You need to create the file /etc/inputrc

You may add to /etc/inputrc something like

Control-g: "clear \n"

The above is a key mapping of cntl-g to clear with enter. If you want shutdown, change it to your favorite shutdown command

Note: if you want to define control keys, make sure they are not used by stty (stty -a will give such info).
see man stty for more info. Please the links below:

http://www.gnu.org/software/bash/manual/bashref.html
http://unixhelp.ed.ac.uk/CGI/man-cgi?readline+3
0
 
zezonsAuthor Commented:
Ok, but I need create a special command like "shutdown_my_system" where if type this sequence in any local console or kde the system should turnoff.
0
 
omarfaridCommented:
Hi,

If you noticed, it does not require typing such long command. It could be a control char to do so.

e.g. in ~/.inputrc add

Control-g: "init 0 \n"

0
 
zezonsAuthor Commented:
But what I need is to modify the kernel code to create a long command, because I know how to create a bash command but I don't need of a bash command.
0
 
zezonsAuthor Commented:
Hi.
I have been changed the "keyboard.c" kernel file.
The change made was in the "put_queue" procedure.

This works fine and give a good known about the kernel sources.

That's all folks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now