Created
June 22, 2018 18:58
-
-
Save bigendiansmalls/b38b8ed873c3e3297bbef4725e2c8e05 to your computer and use it in GitHub Desktop.
signal parser for linux (stolen from stackoverflow)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sigparse () { | |
local i=0 bits | |
# bits="$(printf "16i 2o %X p" "0x$1" | dc)" # variant for busybox | |
bits="$(printf "ibase=16; obase=2; %X\n" "0x$1" | bc)" | |
while [ -n "$bits" ] ; do | |
i="$(expr "$i" + 1)" | |
case "$bits" in | |
*1) printf " %s(%s)" "$(kill -l "$i")" "$i" ;; | |
esac | |
bits="${bits%?}" | |
done | |
} | |
grep "^Sig...:" "/proc/$1/status" | while read a b ; do | |
printf "%s%s\n" "$a" "$(sigparse "$b")" | |
done # | fmt -t # uncomment for pretty-printing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://unix.stackexchange.com/questions/85364/how-can-i-check-what-signals-a-process-is-listening-to