pages tagged signal.hrohieb.namehttps://rohieb.name/blag/tag/signal.h/rohieb.nameikiwiki2013-11-08T23:14:00ZA Lesser-Known Feature of kill(1)https://rohieb.name/blag/post/a-lesser-known-feature-of-kill-1-/rohieb
CC-BY-SA 3.0
2013-11-08T23:14:00Z2013-11-08T23:14:00Z
<h2 id="problem">Problem</h2>
<p>I was debugging a program, which suddenly died with</p>
<pre><code>QFATAL : TestEdge::testSaveRemove() Received signal 11
</code></pre>
<p>For better understanding of the problem, it would be nice to know what
the meaning of “signal 11” is.</p>
<h2 id="solution">Solution</h2>
<p>I was not so fluent in signal numbers (maybe I should take <a href="http://www.memrise.com/course/158486/unix-signals/">a
course</a>). Of course, I <em>could</em> dig in the <a href="http://manpages.debian.net/cgi-bin/man.cgi?query=signal&apropos=0&sektion=7&manpath=Debian+7.0+wheezy&format=html&locale=en"><code>signal(7)</code> man
page</a>, or in the respective C header (<code>signal.h</code>). However,
while digging in the manpages, I noticed that <code>kill(1)</code> does not only
kill processes, but also does exactly what I want.[^1] Citing from the
<a href="http://manpages.debian.net/cgi-bin/man.cgi?query=kill&apropos=0&sektion=0&manpath=Debian+7.0+wheezy&format=html&locale=en">man page</a>:</p>
<pre><code>-l, --list [signal]
List signal names. This option has optional argument, which
will convert signal number to signal name, or other way round.
</code></pre>
<p>[^1]: At least the version in Debian, which is from
<a href="https://gitorious.org/procps">procps</a></p>
<p>So I could just say:</p>
<pre><code>$ kill -l 11
SEGV
</code></pre>
<p>Ah, segmentation fault. Nice to know <img src="https://rohieb.name/smileys/smile.png" alt=":-)" /></p>
<p>In addition, the man page also mentions a useful parameter <code>-L</code>, which
prints a nice table of signal numbers and mnemonics:</p>
<pre><code>$ /bin/kill -L
1 HUP 2 INT 3 QUIT 4 ILL 5 TRAP 6 ABRT 7 BUS
8 FPE 9 KILL 10 USR1 11 SEGV 12 USR2 13 PIPE 14 ALRM
15 TERM 16 STKFLT 17 CHLD 18 CONT 19 STOP 20 TSTP 21 TTIN
22 TTOU 23 URG 24 XCPU 25 XFSZ 26 VTALRM 27 PROF 28 WINCH
29 POLL 30 PWR 31 SYS
</code></pre>
<p>(Also, the man page also warns about <code>kill</code> probably being a shell
built-in. At least the Bash and zsh built-ins also know <code>-l</code>, but not
<code>-L</code>, so you have to call <code>/bin/kill</code> explicitly.)</p>