in reply to Forked off!
The program forks at the $pid=fork and suddenly there are two programs running, both doing the next statement (the if). The only difference is that one will have $pid = 0 and one will have $pid = 1234 or some number, being the pid of the child.
my $pid; $pid = fork; if ( $pid ) { #We are the parent print "Successfully forked, I am the parent\n"; } else { if ( $pid == 0 ) { #We are the child print "Successfully forked, I am the child\n"; } else { #undef value - no fork happened print "Fork failed for some strange reason\n"; } }
I'm currently writing a module to do this and handle IPC as well. If you can hold on a few days I'll clean up the module and post it.
____________________
Jeremy
I didn't believe in evil until I dated it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Forked off!
by larryk (Friar) on Aug 06, 2001 at 20:38 UTC | |
by jepri (Parson) on Aug 06, 2001 at 20:45 UTC |