Syntactic Confectionery Delight | |
PerlMonks |
Re: Confused by fork examplesby reasonablekeith (Deacon) |
on Dec 18, 2005 at 11:28 UTC ( [id://517589]=note: print w/replies, xml ) | Need Help?? |
You don't need to start new process with eval, when you run 'fork' you will already have two exact copies of you program running.
fork creates this dupicate in a child process of the one running the original perl script. The way you tell them apart is by checking the id returned from fork. If the id is 0, you are in the child process. If the id is non-zero, you are in the parent. That non-zero id is the id of the spawned child process. so, after running fork, check the id and condition your code appropriately for the child or the parent
--- my name's not Keith, and I'm not reasonable.
In Section
Seekers of Perl Wisdom
|
|