How to read a sigmask of a process on Linux
Published:
You can get the signal mask of a running process from the /proc
filesystem, but how do you interpret it?
cat /proc/2137/status | grep -P '^Sig'
SigQ: 5/256411
SigPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000028095207
The meaning of the each value is briefly explained by the
proc_pid_status(5)
man page.
For example, the SigCgt field represents the "Mask (expressed in
hexadecimal) indicating signals being caught".
The proc_pid_status(5) man page then refers the reader to
another one, namely signal(7).
The signal(7) man page has a section called Signal numbering for standard signals. This section contains a nice table that shows signals and their numbers on several processor architectures. The same information can also be obtained by running the following command:
/usr/bin/kill -L
You can use this information to interpret the hexadecimal values you
obtained by inspecting the /proc/<pid>/status
file.
Signal with number 1 sets the first bit, signal number 2 sets the second
bit, and so on.
You can also act like a civilised person living in the 21st century, and not a bloody savage, and let the computer do the work for you:
/usr/bin/kill -l 0x0000000028095207
HUP
INT
QUIT
USR1
PIPE
TERM
CHLD
TSTP
WINCH
PWR
Just keep in mind that you must use the kill(1) command
from the util-linux package, not the built-in of your
shell.
This is the reason why the examples used /usr/bin/kill ie,
the full path to the executable, instead of just kill.
Previous: Programming and terminal fonts