SIGTERM with a keyboard shortcut

consolekillprocesssignalterminal

I know that inside a terminal, Ctrl+C keyboard shortcut will send a SIGINT signal to the current foreground process. Is there a way to setup a keyboard shortcut for sending SIGTERM or even SIGKILL to the current process? I think it could save me some time.

I'm running Ubuntu 11.04

Best Answer

stty is responsible for controlling this, you may already have one setup. You can check by doing:

$ stty -e
speed 38400 baud; 53 rows; 225 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
        -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff -ixany imaxbel -iutf8
        -ignbrk brkint -inpck ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd -hupcl -clocal -cstopb -crtscts
        -dsrflow -dtrflow -mdmbuf
discard dsusp   eof     eol     eol2    erase   intr    kill    lnext   
^O      ^Y      ^D      <undef> <undef> ^?      ^C      ^U      ^V      
min     quit    reprint start   status  stop    susp    time    werase  
1       ^\      ^R      ^Q      ^@      ^S      ^Z      0       ^W      

The last few lines should look familiar, ^C=intr is the one you mentioned in your question. You can read how to set more via:

$ man stty
Related Question