Skip to content

Instantly share code, notes, and snippets.

@kurahaupo
Last active Dec 29, 2015
Embed
What would you like to do?
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