Skip to content

Instantly share code, notes, and snippets.

@tachang
Created October 29, 2020 01:27
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 tachang/9e7e8e4f6357fbbb5bce5dbe67704687 to your computer and use it in GitHub Desktop.
Save tachang/9e7e8e4f6357fbbb5bce5dbe67704687 to your computer and use it in GitHub Desktop.
sigparse () {
i=0
# 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