Skip to content

Instantly share code, notes, and snippets.

@kurahaupo
Last active December 29, 2015 12:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurahaupo/7669956 to your computer and use it in GitHub Desktop.
Save kurahaupo/7669956 to your computer and use it in GitHub Desktop.
Show signal names from Sig* lines in Linux's /proc/$PID/status
#!/bin/bash
pid=${1:-$PPID}
signals="$(trap -l)"
declare -A SIG
for s in ${signals//') '/=}
do
i=${s%%=*}
n=${s#*=}
[[ $n = *[-+]* ]] && continue
SIG["$n"]="$i"
NUM[$i]="$n"
done
grep ^Sig /proc/$pid/status |
while read phase mask
do
echo "$phase $mask $( for s in ${!NUM[@]} ; do (( 0x$mask & ( 1 << (s-1) ) )) && echo "${NUM[s]}" ; done )"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment