new blag post: A Lesser-Known Feature of kill(1)
[www-rohieb-name.git] / blag / post / a-lesser-known-feature-of-kill-1-.mdwn
1 [[!meta title="A Lesser-Known Feature of kill(1)"]]
2 [[!meta author="rohieb"]]
3 [[!meta license="CC-BY-SA 3.0"]]
4
5 ## Problem ##
6 I was debugging a program, which suddenly died with
7
8 QFATAL : TestEdge::testSaveRemove() Received signal 11
9
10 For better understanding of the problem, it would be nice to know what
11 the meaning of “signal 11” is.
12
13
14 ## Solution ##
15 I was not so fluent in signal numbers (maybe I should take [a
16 course][memrise]). Of course, I _could_ dig in the [`signal(7)` man
17 page][mansignal], or in the respective C header (`signal.h`). However,
18 while digging in the manpages, I noticed that `kill(1)` does not only
19 kill processes, but also does exactly what I want.[^1] Citing from the
20 [man page][mankill]:
21
22 -l, --list [signal]
23 List signal names. This option has optional argument, which
24 will convert signal number to signal name, or other way round.
25
26 [^1]: At least the version in Debian, which is from
27 [procps](https://gitorious.org/procps)
28
29 So I could just say:
30
31 $ kill -l 11
32 SEGV
33
34 Ah, segmentation fault. Nice to know :-)
35
36 In addition, the man page also mentions a useful parameter `-L`, which
37 prints a nice table of signal numbers and mnemonics:
38
39 $ /bin/kill -L
40 1 HUP 2 INT 3 QUIT 4 ILL 5 TRAP 6 ABRT 7 BUS
41 8 FPE 9 KILL 10 USR1 11 SEGV 12 USR2 13 PIPE 14 ALRM
42 15 TERM 16 STKFLT 17 CHLD 18 CONT 19 STOP 20 TSTP 21 TTIN
43 22 TTOU 23 URG 24 XCPU 25 XFSZ 26 VTALRM 27 PROF 28 WINCH
44 29 POLL 30 PWR 31 SYS
45
46 (Also, the man page also warns about `kill` probably being a shell
47 built-in. At least the Bash and zsh built-ins also know `-l`, but not
48 `-L`, so you have to call `/bin/kill` explicitly.)
49
50 [memrise]: http://www.memrise.com/course/158486/unix-signals/
51 [mansignal]: http://manpages.debian.net/cgi-bin/man.cgi?query=signal&apropos=0&sektion=7&manpath=Debian+7.0+wheezy&format=html&locale=en
52 [mankill]: http://manpages.debian.net/cgi-bin/man.cgi?query=kill&apropos=0&sektion=0&manpath=Debian+7.0+wheezy&format=html&locale=en
53
54 [[!tag UNIX Linux Debian UNIX_signal_numbers signal.h SIGSEGV kill]]
This page took 0.242026 seconds and 5 git commands to generate.