Handling and propagating signals

Daniel Barlow dan at coruskate.net
Thu Feb 1 17:34:25 GMT 2007


David Cantrell wrote:
> Someone just reported what I'm inclined to treat as a bug in rsnapshot.
> Boiled down to a minimal example, it's this:
> 
> perl -e '$SIG{TERM} = sub { exit() }; system("sleep 60")'
> 
> Now send that process a SIGTERM.  The perl process promptly exits.  The
> command I ran using system(), however, does not.  I want my signal
> handler to propagate the signal to children as well.
> 
> Because the signal is received while perl is waiting for system() to
> return, I can't see any way in which I can possibly know the child's
> PID without having to grovel through the process table.

On a sufficiently compliant POSIX^W"Single UNIX(R)" system, in C, you
could use waitid() for this purpose.  The POSIX perl module doesn't seem
to support this call yet, though (at least, not according to its
documentation in 5.8.8) so this might not be the immediately useful
response you were looking for.

http://www.opengroup.org/onlinepubs/007908799/xsh/waitid.html
http://www.opengroup.org/onlinepubs/007908799/xsh/signal.h.html # for
siginfo_t


-dan

-- 
http://www.coruskate.net/


More information about the london.pm mailing list