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

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

Thread Next
From:
Stephen P. Potter
Date:
December 11, 2000 19:51
Subject:
[ID 19991118.011] IPC::Open3 calls die, not exit, on exec failure
Message ID:
200012120353.WAA01776@spotter.yi.org
This bug appears to still be active.


 In IPC::Open3.pm, version 1.0101, line 188/189, there is the following 
 code. 

         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
executing
 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 Open3.pm 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About