Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Getting the source of a signal

by nitin1704 (Sexton)
on Nov 30, 2012 at 06:28 UTC ( #1006416=perlquestion: print w/replies, xml ) Need Help??
nitin1704 has asked for the wisdom of the Perl Monks concerning the following question:

I have a subroutine to handle the USR1 signal. I would like to know which process is invoking this signal. Is there a way to do that?
$SIG{USR1} = sub { #code }

Replies are listed 'Best First'.
Re: Getting the source of a signal
by moritz (Cardinal) on Nov 30, 2012 at 07:44 UTC

      POSIX sigaction might give you access to the pid, BUT the docs say it's not often implemented

      sigaction Detailed signal management. This uses POSIX::SigAction objects for + the action and oldaction arguments (the oldaction can also be just a + hash reference). Consult your system's sigaction manpage for details +, see also POSIX::SigRt. ... The following are also defined by POSIX/SUSv3, but unfortunately not v +ery widely implemented: pid the process id generating the signal uid the uid of the process id generating the signal status exit value or signal for SIGCHLD band band event for SIGPOLL
Re: Getting the source of a signal
by Anonymous Monk on Nov 30, 2012 at 20:32 UTC
    Don't count on it. "No."

    If the process needs to know "who" or "why," you should be sending that process a message over some kind of pipe or other interprocess-communication mechanism.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1006416]
Approved by moritz
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2017-05-28 03:56 GMT
Find Nodes?
    Voting Booth?