in reply to Re^2: close statement issue
in thread close statement issue

Huh? I first discovered waitpid precisely because it doesn't, at least on SUNOS with v 5.005 and I had sysadms asking me to do something about the zombies being left in the air when I closed the pipe and returned without wait.

-M

Free your mind

Replies are listed 'Best First'.
Re^4: close statement issue
by ysth (Canon) on Mar 02, 2007 at 12:10 UTC
    I don't know what to tell you; it most certainly does in current perls, and based on the doc, did so in 5.005 too. Try this:
    $ perl -we'open FOO, q<| sh -c "sleep 5;exit 123"> or die; print "clos +ing:\n"; close FOO; print $? >> 8' closing: 123
    to verify that close() is waiting for the process to finish and putting its status in $?.

    (Update: removed lexical filehandle; I'd really like to see you try the above on your SunOS 5.005.)

      Looking at the documentation you were reading, I think I can understand your confusion. Closing the pipe at one end is not synonymous (or to make it clearer what is happening 'not simultaneous') with termination of the subprocess.

      If a parent closes its end of a pipe and doesn't wait for the child to terminate, the subprocess can become a zombie under SunOS - I discovered waitpid for the first time during the successful process of investigating and solving the problem.

      I am talking reality here, not supposition or documentation.

      Update: I am not convinced by the example which does nothing with the pipe - When I have time, I'll try to reproduce the actual case with some "ps"s to show the zombies.

      -M

      Free your mind