Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Getting the source of a signal

by nitin1704 (Sexton)
on Nov 30, 2012 at 06:28 UTC ( [id://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!

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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-19 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found