Notification on parent death - Unix
This is a discussion on Notification on parent death - Unix ; Hi All,
We all know that SIGCLD or SIGCHLD is delivered to the parent on
the death of its child. Similary, why the parent cannot send a signal
to its children on its (parent's) death?
TIA.
Regards,
Seenu....
-
Notification on parent death
Hi All,
We all know that SIGCLD or SIGCHLD is delivered to the parent on
the death of its child. Similary, why the parent cannot send a signal
to its children on its (parent's) death?
TIA.
Regards,
Seenu.
-
Re: Notification on parent death
On Dec 3, 10:38 pm, seen...@gmail.com wrote:
> Hi All,
> We all know that SIGCLD or SIGCHLD is delivered to the parent on
> the death of its child. Similary, why the parent cannot send a signal
> to its children on its (parent's) death?
There is a natural reason for a parent to need to know when its child
has died: so that it can call wait*(2). When a parent dies, a child
doesn't in general necessarily have to do anything.
Admittedly the SIGCHLD mechanism is a bit ad-hoc and one could
certainly wish for a more general notification scheme. Some systems
might have this sort of thing but I don't think there is anything
standard.
If you need this for something specific, a simple way would be for the
parent to use atexit() to explicitly send a signal as it exits. Of
course this won't help if the process is killed without calling
exit(). You could also arrange for there to be a "grandparent"
process which will be notified when the parent dies. Or have the
child periodically check whether getppid() has changed to 1.
-
Re: Notification on parent death
In article ,
fjblurt@yahoo.com wrote:
> On Dec 3, 10:38 pm, seen...@gmail.com wrote:
>> Hi All,
>> We all know that SIGCLD or SIGCHLD is delivered to the parent on
>> the death of its child. Similary, why the parent cannot send a signal
>> to its children on its (parent's) death?
>
> There is a natural reason for a parent to need to know when its child
> has died: so that it can call wait*(2). When a parent dies, a child
> doesn't in general necessarily have to do anything.
>
> Admittedly the SIGCHLD mechanism is a bit ad-hoc and one could
> certainly wish for a more general notification scheme. Some systems
> might have this sort of thing but I don't think there is anything
> standard.
>
> If you need this for something specific, a simple way would be for the
> parent to use atexit() to explicitly send a signal as it exits. Of
> course this won't help if the process is killed without calling
> exit().
How about the parent keeping a file descriptor open with the child? If
the parent is killed, that file descriptor will be closed on the
parent's side, and the child could readily find out with select().
> You could also arrange for there to be a "grandparent"
> process which will be notified when the parent dies. Or have the
> child periodically check whether getppid() has changed to 1.