FAQ
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.

Search Discussions

  • Barries at Dec 12, 2000 at 6:32 am

    On Mon, Dec 11, 2000 at 10:53:36PM -0500, Stephen P. Potter wrote:

    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.
    If there are things waiting to be DESTROYed that will have effects
    outside of the process, like cleaning up files or releasing locks,
    then this will cause resources probably still needed by the parent to be
    cleaned up by the child.

    I've had to resort to "kill 9, $$" in the past to work around this, thus
    immediately limiting my module's portability.

    Is there any way to exit perl and skip DESTROYs? Or, better yet, to
    simulate the bypassing of DESTROYs by exec()? I've had some need to
    spawn coprocesses (encapsulated as a sub) which then had to kill 9, $$ to
    avoid unwanted cleanups.

    Both of these came up most recently in the vcp stuff I'm trying to use
    to do p4->cvs replication, actually.

    - Barrie
  • Tony Cook at Dec 12, 2000 at 7:33 am

    On Tue, 12 Dec 2000, barries wrote:
    Is there any way to exit perl and skip DESTROYs? Or, better yet, to
    simulate the bypassing of DESTROYs by exec()? I've had some need to
    spawn coprocesses (encapsulated as a sub) which then had to kill 9, $$ to
    avoid unwanted cleanups.
    use POSIX "_exit";
    package Foo;
    sub DESTROY {
    print "foo::destroy\n";
    }
    package main;
    $x = bless {}, "Foo";
    _exit(0)

    prints nothing. Maybe you want _exit().

    Tony
  • Nick Ing-Simmons at Dec 12, 2000 at 8:37 am

    Barries writes:

    Is there any way to exit perl and skip DESTROYs? Or, better yet, to
    simulate the bypassing of DESTROYs by exec()?
    I have had some success with

    exec(@list) || exec("/bin/false");

    --
    Nick Ing-Simmons <nik@tiuk.ti.com>
    Via, but not speaking for: Texas Instruments Ltd.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedDec 12, '00 at 3:51a
activeDec 12, '00 at 8:37a
posts4
users4
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase