KTFM (Killing the Fine Manual)
In a recent newgroup thread, someone was looking for a shell equivalent to "killpg" (a system call that sends a signal to a process group). Someone who really should have known better answered with one word: "kill". The original poster shortly replied with something like "Gee, I didn't know I could use anything but PID's with kill" and got another laconic response: " Read the man page."
And of course he had, though not carefully. The syntax for specifying a process group rather than a pid is to prefix the process group number with a "-" (or "--" so you can leave out the signal itself for the default kill).
However, that's not the whole story. Shells like bash override kill with their own function, which has different syntax and options. So someone who had read "man kill" but not the kill section in "man bash" could be further confused. Looky here, for example:
$ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR 31) SIGSYS 33) SIGRTMIN 34) SIGRTMIN+1 35) SIGRTMIN+2 36) SIGRTMIN+3 37) SIGRTMIN+4 38) SIGRTMIN+5 39) SIGRTMIN+6 40) SIGRTMIN+7 41) SIGRTMIN+8 42) SIGRTMIN+9 43) SIGRTMIN+10 44) SIGRTMIN+11 45) SIGRTMIN+12 46) SIGRTMIN+13 47) SIGRTMIN+14 48) SIGRTMIN+15 49) SIGRTMAX-15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1 64) SIGRTMAX $ /bin/kill -l HUP INT QUIT ILL ABRT FPE KILL SEGV PIPE ALRM TERM USR1 USR2 CHLD CONT STOP TSTP TTIN TTOU TRAP IOT BUS SYS STKFLT URG IO POLL CLD XCPU XFSZ VTALRM PROF PWR WINCH UNUSED
It's interesting that /bin/kill doesn't mind using the long form signal names and bash doesn't mind using the short:
$ /bin/kill -s SIGHUP 1207 kill 1207: No such process $ /bin/kill -s HUP 1207 kill 1207: No such process $ kill -s HUP 1207 -bash: kill: (1207) - No such process $ kill -s SIGHUP 1207 -bash: kill: (1207) - No such process
But don't try giving /bin/kill any of that bash extra stuff:
$ kill -s SIGRTMAX 1207 -bash: kill: (1207) - No such process $ /bin/kill -s SIGRTMAX 1207 kill: unknown signal SIGRTMAX; valid signals: HUP INT QUIT ILL ABRT FPE KILL SEGV PIPE ALRM TERM USR1 USR2 CHLD CONT STOP TSTP TTIN TTOU TRAP IOT BUS SYS STKFLT URG IO POLL CLD XCPU XFSZ VTALRM PROF PWR WINCH UNUSED
By the way, for the original question, "killall" has a -g option to kill process groups.
Got something to add? Send me email.
(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version
Increase ad revenue 50-250% with Ezoic