Skip to content

Instantly share code, notes, and snippets.

@bigendiansmalls
Created June 22, 2018 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigendiansmalls/b38b8ed873c3e3297bbef4725e2c8e05 to your computer and use it in GitHub Desktop.
Save bigendiansmalls/b38b8ed873c3e3297bbef4725e2c8e05 to your computer and use it in GitHub Desktop.
signal parser for linux (stolen from stackoverflow)
#!/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