Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Forking and running all child processes at the same time

by tlm (Prior)
on Jun 06, 2005 at 12:33 UTC ( [id://463895]=note: print w/replies, xml ) Need Help??


in reply to Forking and running all child processes at the same time

for my $file ( <*.log> ) { # for example... defined( my $pid = fork ) or die "Unable to fork: $!"; unless ( $pid ) { # in child # process $file exit; } } 1 while wait > 0; # avoid zombies

the lowliest monk

Replies are listed 'Best First'.
Re^2: Forking and running all child processes at the same time
by jimbojones (Friar) on Jun 06, 2005 at 14:34 UTC
    Hi
    As pointed out by BrowserUK in this node Re: Unix Review column, your:
    1 while wait > 0; # avoid zombies
    won't work on windows systems. The windows implementation uses the negative of the thread ID as the pid, so wait returns negative numbers for all children.

    It seems the most cross-platform wait statement is:
    1 while wait != -1 ; # avoid zombies
    since the main thread is ID 1, and the child threads won't have that ID. And it's what wait natively returns when there are no further child processes.

    - j

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-25 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found