in reply to How to asynchronisly get notified of a child exit

It sounds as if you need a child to do the parent's blocking tasks. The parent should be a controller or do it's own work, but preferably not both. Can you not move the parent's work into a child process? Then you would be able to monitor all children and separate your concerns.

What you could possibly do (and I don't know if there's any guarantees on this) is capture the parent pid in a variable before forking, then make an SIG{__DIE__} block that signals the parent PID with a HUP or something similar. Kludgey at best though =/
  • Comment on Re: How to asynchronisly get notified of a child exit

Replies are listed 'Best First'.
Re^2: How to asynchronisly get notified of a child exit
by Mostly Harmless (Initiate) on Jul 07, 2005 at 18:17 UTC
    <quote> It sounds as if you need a child to do the parent's blocking tasks. </quote>

    Yes, that would have been perferrable. But as I mentioned earlier, it'd need lots of changes to the legacy code, which is not feasible. Also, I want to spawn a process only for very select tasks, as there's a danger of system being overlaoded with too many processes.

    <quote> en make an SIG{__DIE__} block that signals the parent PID with a HUP </quote>

    That's a good idea. But this won't work when child hits fatal errors like receiving a SIGKILL or SEGV.

    PS: New to perlmonks. Not sure how to quote msgs, and too lazy to read up right now ;-)