develooper Front page | perl.perl5.porters | Postings from December 2000

[ID 19991118.011] IPC::Open3 calls die, not exit, on exec failure

Thread Next
Stephen P. Potter
December 11, 2000 19:51
[ID 19991118.011] IPC::Open3 calls die, not exit, on exec failure
Message ID:
This bug appears to still be active.

 In, version 1.0101, line 188/189, there is the following 

         exec @cmd
             or croak "open3: exec of @cmd failed";

 This code is executed after the process has forked.  This has the large
 problem that if you run the code in an eval block, your child process will 
 break out to the top of the block rather than die.

 This caused a big problem for us, because we have code that runs in a
 loop and executes functions in eval blocks.  The parent process was
 an open3 command and the program to run wasn't in the path.  The exec
 in the child process failed and the child process dropped back to the
 end of the eval in the loop.  The parent sat waiting for the child to
 terminate, and the child kept running in the loop.  The next phase of
 the loop caused the same problem, and this kept happening until we had
 40 copies of the application running and the server ran out of memory.

 An easy solution to this problem is to make line 188 of print
 the error to STDERR and call exit rather than calling croak.  The Open3
 caller can then check the STDERR for the error.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About