raflach has asked for the wisdom of the Perl Monks concerning the following question:
if ( $child = fork ) { #Do Parent stuff here } else { while ( $child2 = fork ) { # fork 2nd child, wait for wait; # it to finish and re-fork } # Do second level child stuff here # Every time we finish, child # 1 starts us again exit; }
if ( $child = fork ) { close PARENTWRITE; # Not needed in parent while ( ! $child2data ) { $child2data = <PARENTREAD>; } # Do Parent stuff here # after ensuring that child2 started } else { close PARENTREAD; # Not needed in child # Do some processing while ( $child2 = fork ) { # fork 2nd child, wait for wait; # it to finish and re-fork } # Do second level child init stuff here print PARENTWRITE 1; # Let parent know we started good # Do more second level child processing # Every time we finish, child # 1 starts us again exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mutiple forks
by Fastolfe (Vicar) on Sep 27, 2000 at 23:08 UTC |