in reply to wait versus close on a pipe
If somehow you get out of sync with wait and it returns -1, you might interpret it incorrectly.... my $pid = wait; if ($pid == $pid1) { ... $pid1 = -1; # indicate child1 has been reaped } ...
I would code the reaping loop something like this:
For a non-blocking version of wait, see perldoc -f waitpid.while (1) { my $pid = wait; last if $pid < 0; if ($pid == $pid1) { ... } elsif ($pid == $pid2) { ... } }
|
|---|