Tuesday, September 30, 2008

A useful tool to print the signals status

I have written a useful tool that will help in analyzing the signal disposition for a given process. It will take the list of PIDs as input and will print the signal disposition of that process in a readable form. For e.g.
5877: SigQ: 0/4096
5877: SigPnd: None (mask 0000000000000000)
5877: SigBlk: None (mask 0000000000000000)
5877: SigIgn: SIGHUP, SIGUSR2, SIGWINCH, SIGIO (mask 0000000030001002)
5877: SigCgt: SIGALRM (mask 0000000000004001)

The first column is the PID and the second column is the disposition and the the third column is the list of signals in a readable form.

It is a Python script. You can download that from here.

By default, the script doesn't print the real-time signals. To force it, you can specify the -r option in the command line. Sometimes there are signals for which there is no name available (for e.g. Signal 0). If such is the case, it will simply say 'Signal X'. There is no option to print the signal status of all the threads under the given process ID. If you know the thread ID ("ps -Leaf"), you can specify that to get the relevant information.

You can get the help for this script using -h. I have tested it in my Ubuntu box running kernel 2.6.24. Please drop me a word if you feel I can improve anything.

No comments: