in reply to IO::Select, IO::Pipe, fork, Data loss
Modifying a list you're using in a for loop is a really bad idea.
foreach my $c ( @{$child_aref} ) { @{$child_aref} = grep { $_ ne $c } @{$child_aref} if ( + waitpid($c, WNOHANG) < 0 );
The help in perlsyn says this :-
If any part of LIST is an array, "foreach" will get very confused if y +ou add or remove elements within the loop body, for example with "splice" +. So don't do that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: IO::Select, IO::Pipe, fork, Data loss
by cyadav (Initiate) on Aug 05, 2015 at 13:22 UTC | |
by RichardK (Parson) on Aug 05, 2015 at 15:43 UTC |