in reply to Timeout with SIG{ALRM} not working as expected

Not sure if that's your intention, but if the child process takes too long, you kill the parent (non-fatally, since it's done inside an eval). You make no attempt to kill the child. So, after a time-out, the parent goes on its merry way while neither closing the pipe, nor doing a wait. Bad things (for some value of bad) will happen: if the child has finished before the parent, the child will become a zombie (because you didn't wait for it) - and if the parent finished before the child, the child might die due to a SIGPIPE if it writes to the pipe after the parent has finished.
  • Comment on Re: Timeout with SIG{ALRM} not working as expected

Replies are listed 'Best First'.
Re^2: Timeout with SIG{ALRM} not working as expected
by MorgothSauron (Initiate) on Jan 19, 2005 at 11:53 UTC
    I forgot to add the code just after the eval:
    if ($@ and $@ =~ /ALARM_COMMAND_TIMEOUT/) { &writeLog("Killing child process (pid = $childPID)"); kill(1, $childPID); }