Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 chanting in the Monastery: (11)
As of 2014-09-22 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (185 votes), past polls