How can a child learn of its parents termination?

Paul Dow CRI-UK paul at sequoia.cray.com
Thu Apr 4 19:02:59 AEST 1991


In article <94559 at lll-winken.LLNL.GOV>, booloo at lll-crg.llnl.gov (Mark Boolootian) writes:
|> The subject pretty much says it all:  Is it possible for a child to receive
|> notification of its parent's termination?  One possibility would be to check
|> the parent process id from time to time but this won't help me.  I have a
|> child sleeping on a semaphore, normally awakened by the parent.  If the parent
|> terminates, the child is going to sleep forever.  I need some way of waking
|> the child up upon parent's death so that the child may exit.
|> 

A couple of ideas might be:

1) Use the SEM_UNDO option for a semaphore - this can be used to adjust the value
   of a semaphore when a process exits.

2) Use a pipe between the parent & child process.  The child could then detect
   the loss of the pipe.

It sounds to me as if option 1) is what will provide what you're looking for.

Paul.



More information about the Comp.unix.questions mailing list