Differences between revisions 5 and 6
Revision 5 as of 2008-01-13 14:31:33
Size: 3129
Editor: 218-186-12-10
Comment:
Revision 6 as of 2008-01-20 04:27:11
Size: 3188
Editor: cm7
Comment:
Deletions are marked like this. Additions are marked like this.
Line 14: Line 14:

 * http://www.kernel.sg/blog/2008/01/13/psig-for-linux/

psig for Linux

Problem

psig is a Solaris proc utility for listing the signal actions and handlers of a process. Anyone who uses Linux would know that there is no equivalent tool in Linux, and getting information related to the process signals’ disposition is not trivial, so I decided to write one using SystemTap.

The version of psig I wrote looks very much like the Solaris’ psig tool but it is not a port. It was written based on the example output of “Comparison of Solaris OS and Linux for Application Developers” article, and it is licensed GPL.

Here is how it looks like when I run the script:

$ psig $$ | egrep ":|^HUP|^SEGV|^BUS"
5981:    bash
HUP      caught   0x0808d040  0  HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,
  ALRM,TERM,XCPU,XFSZ,VTALRM,SYS
BUS      caught   0x0808d040  0  HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,
  ALRM,TERM,XCPU,XFSZ,VTALRM,SYS
SEGV     caught   0x0808d040  0  HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,
  ALRM,TERM,XCPU,XFSZ,VTALRM,SYS

From here, we can tell that the signals SIG{HUP,BUS,SEGV} have the same signal handler at address 0x0808d040. The output may look daunting but it is actually easy to understand.

Let’s look closer at the SIGHUP signal:

HUP      caught   0x0808d040  0  HUP,INT,ILL,TRAP,ABRT,BUS,...

From here, we can see that:

  • HUP is a type of signal.
  • caught means that it has a handler associated to the signal. It can also be associated with SIG_{DFL,IGN,ERR} signal action.
  • 0x0808d040 is the userspace address of the handler.
  • 0 refers to the sa_flags. It can be SA_{ONSTACK,RESTART,NOCLDSTOP,etc}. See asm/signal.h.

  • HUP,INT,ILL,TRAP,ABRT,BUS... is a set of signals to be blocked when it executes the handler.

So if you are interested, you can download and install the latest version of SystemTap, download psig.sh, patch the tapset/signal.stp script, and you are all set to play with psig. I will be submitting my signal tapset changes to the upstream, and hopefully it will be accepted.

psig.sh signal.stp-psig.patch signal.stp signal.stp.default


WarStories

None: WSPsig (last edited 2008-01-20 04:27:11 by cm7)