Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Proper Forking

by nardo (Friar)
on Jul 24, 2001 at 23:17 UTC ( #99455=note: print w/replies, xml ) Need Help??

in reply to Proper Forking

In the child process you:
sleep 1 until getppid == 1;
which will loop until the child processes parent is pid 1 which will happen after the parent terminates. Then in the parent you:
which will wait for the child to terminate. So you have the child waiting for the parent to terminate and the parent waiting for the child to terminate thus they are both stuck. Normally when you fork you don't wait for your parent to be init so i would get rid of the sleep until line, also the example you provided might just as well be written without a fork since the parent does nothing other than wait for the child to finish its job the parent could just as well have done that job instead.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2022-05-25 04:07 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (84 votes). Check out past polls.