Shell – Why doesn’t ctrl+u send SIGKILL? stty says it should

killshellsignalstty

I can interrupt a program by pressing ctrl+c in the shell. Often this kills the program but some programs trap the signal and keep running.

I want to be able to kill such programs more aggressively and did some research. I read that stty -a will list tty shortcuts. Here is the output:

speed 38400 baud; rows 27; columns 213; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

Let me draw your attention to

intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; [...]

Two of those look familiar: ^C and ^D, and it looks like ^U should send sigkill, which I believe should be like kill -9.

In my particular case, I want to kill ddd, which is otherwise difficult to close sometimes. If I crtl+u from the shell, it has no effect, although kill -9 on its PID will kill it.

Am I wrong in interpreting this output from stty -a? Should ctrl+u send SIGKILL? Why didn't this work as expected? Or, how can I conveniently send SIGKILL from the shell (i.e. the shell which ddd was launched from)?

Best Answer

That kill is for character assassination, not death by signal. It should be documented in a the termios(4) man page,

Erase and kill processing occur when either of two special characters, the ERASE and KILL characters (see the Special Characters section), is received. This processing affects data in the input queue that has not yet been delimited by a newline NL, EOF, or EOL character. This undelimited data makes up the current line. The ERASE character deletes the last character in the current line, if there is any. The KILL character deletes all data in the current line, if there is any.

or termios(3) on linux

VKILL (025, NAK, Ctrl-U, or Ctrl-X, or also @) Kill character (KILL). This erases the input since the last EOF or beginning-of-line. Recognized when ICANON is set, and then not passed as input.