Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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 }
Thanks!

Comment on Getting the source of a signal
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1006416]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-08-30 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (289 votes), past polls