nomis80 has asked for the wisdom of the Perl Monks concerning the following question:
Problem is: sometimes, with a particular @command, the parent just idles while the child has become a zombie. I want to know if the above is safe from zombies, ie. it will *never* under any circumstance idle while the child is a zombie. The documentation of close says:defined( my $pid = open( FROM_CHILD, "-|" ) ) or die "can't fork: $!"; if ($pid) { my @output = <FROM_CHILD>; close FROM_CHILD; } else { open STDERR, ">&STDOUT" or die "Can't dup STDOUT"; exec @command or die "can't exec: $!"; }
Closing a pipe also waits for the process executing on the pipe to complete, in case you want to look at the output of the pipe afterwards, and implicitly puts the exit status value of that command into $?.It seems to me that the close should reap the zombie. So I guess the parent is idling while reading the child's output. How can it not idle? Why does it idle? Thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Protection from zombies
by mda2 (Hermit) on May 16, 2005 at 20:46 UTC | |
Re: Protection from zombies
by tlm (Prior) on May 16, 2005 at 20:37 UTC | |
by sgifford (Prior) on May 16, 2005 at 21:58 UTC | |
by mda2 (Hermit) on May 16, 2005 at 22:58 UTC | |
by sgifford (Prior) on May 17, 2005 at 04:05 UTC | |
by nomis80 (Sexton) on May 17, 2005 at 12:40 UTC | |
by nomis80 (Sexton) on May 17, 2005 at 12:50 UTC | |
| |
Re: Protection from zombies
by kscaldef (Pilgrim) on May 16, 2005 at 23:07 UTC | |
by nomis80 (Sexton) on May 17, 2005 at 12:07 UTC | |
by kscaldef (Pilgrim) on May 17, 2005 at 17:53 UTC | |
by sgifford (Prior) on May 19, 2005 at 21:39 UTC | |
Re: Protection from zombies
by sgifford (Prior) on May 16, 2005 at 22:01 UTC | |
by nomis80 (Sexton) on May 17, 2005 at 12:05 UTC |