Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: IO::Select, IO::Pipe, fork, Data loss

by RichardK (Parson)
on Aug 05, 2015 at 12:52 UTC ( [id://1137506]=note: print w/replies, xml ) Need Help??


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

    Ok, I've corrected that, but I think that's not going to resolve the problem.

      There's only one way to find out, stop guessing and test it ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1137506]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2024-04-16 21:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found