1 Reply Latest reply: Sep 23, 2009 4:40 AM by 807559 RSS

    Looking in siginfo to find who sent this signal

    807559
      Hello,

      I am trying to trace the source of all signals received by a process.

      As I read the documentation, the proc:::signal-handle probe will fire when a thread is about to receive a signal and will have args[1] either NULL or containing a siginfo_t structure.

      I can print out the signal code using

      dtrace -n "proc:::signal-handle
      /pid==$MYPID && args[1]!=NULL/
      {
      printf(\"Thread %d about to handle signal %d code %d\n\",
      tid,arg0,args[1]->si_code);
      }"

      But when I try to print the pid of the sender from args[1]->si_pid, (which should be available when si_code<=0)
      using

      dtrace -n "proc:::signal-handle
      /pid==$MYPID && args[1]!=NULL && args[1]->si_code<=0/
      {
      printf(\"Thread %d about to handle signal %d pid %d\n\",
      tid,arg0,args[1]->si_pid);
      }"

      I get

      dtrace: invalid probe specifier proc:::signal-handle
      /pid==18568 && args[1]!=NULL && args[1]->si_code<=0/
      {
      printf("Thread %d about to handle signal %d pid %d\n",
      tid,arg0,args[1]->si_pid);
      }: in action list: si_pid is not a member of struct siginfo

      Is Dtraces' struct siginfo differant from the siginfo_t on Solaris 10?
      Can anybody tell me the right way to find who sent a signal?

      Thanks
      -- Steve
        • 1. Re: Looking in siginfo to find who sent this signal
          807559
          Got it.

          The siginfo structure does not really have a si_pid member.
          It is defined in /usr/include/sys/siginfo.h as

          #define si_pid __data.__proc.__pid

          which Dtrace doesn't know about. So I just need to say

          dtrace -n "proc:::signal-handle
          /pid==$MYPID && args[1]!=NULL && args[1]->si_code<=0/
          {
          printf(\"Thread %d about to handle signal %d pid %d\n\",
          tid,arg0,args[1]->__data.__proc.__pid);
          }"

          and all is well.

          -- Steve