Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: waitpid for child #1 inside child #2: any way to make it work?

by shmem (Chancellor)
on May 07, 2014 at 02:07 UTC ( #1085264=note: print w/replies, xml ) Need Help??

in reply to waitpid for child #1 inside child #2: any way to make it work?

Question: Is there a way to make child #2 know about $pid1 such that waitpid($pid1) inside child #2 works?

No. waitpid($pid1) inside child #2 will never work.The parent waits for the child, not the other way round. Grandfather doesn't wait for grandsons, and the reverse holds, too.

For the first child (which you name parent2), $pid1 is the parent pid. Inside that child you can get at the $pid1 via getppid. If you want to get the pid from the grandfather in the grandson, the grandson has to ask its father via some other IPC mechanism. Then the grandson may kill 0, $grandfatherpid to see if the grandfather process is still alive. See kill.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1085264]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-05-21 02:29 GMT
Find Nodes?
    Voting Booth?