Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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'


Comment on Re: waitpid for child #1 inside child #2: any way to make it work?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2014-07-31 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (244 votes), past polls