Skip to content

Instantly share code, notes, and snippets.

@aktau
Created May 12, 2013 11:46
Show Gist options
  • Save aktau/5563282 to your computer and use it in GitHub Desktop.
Save aktau/5563282 to your computer and use it in GitHub Desktop.
inspect the signal set of every thread in a process (including the main thread) TODO: decode the
#!/bin/bash
set -e
set -u
pid=$1
# SigQ number of signals queued/max. number for queue
# SigPnd bitmap of pending signals for the thread
# ShdPnd bitmap of shared pending signals for the process
# SigBlk bitmap of blocked signals
# SigIgn bitmap of ignored signals
# SigCgt bitmap of catched signals
# The strings are generated by render_sigset_t() in
# kernel/sched.c, which looks like this:
# char *render_sigset_t(sigset_t *set, char *buffer) {
# int i = _NSIG, x;
# do {
# i -= 4, x = 0;
#
# if (sigismember(set, i+1)) x |= 1;
# if (sigismember(set, i+2)) x |= 2;
# if (sigismember(set, i+3)) x |= 4;
# if (sigismember(set, i+4)) x |= 8;
#
# *buffer++ = (x < 10 ? '0' : 'a' - 10) + x;
# } while (i >= 4);
#
# *buffer = 0;
# return buffer;
# }
for f in /proc/$pid/task/*/status
do
echo "proc -> $f "
egrep '^Name|^Sig|^Shd' $f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment