Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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

by shmem (Canon)
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2016-10-25 05:24 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (315 votes). Check out past polls.