Link to home
Start Free TrialLog in
Avatar of zezons
zezons

asked on

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.
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

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
Avatar of zezons
zezons

ASKER

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.
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"

Avatar of zezons

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of zezons
zezons

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial