Alex Rivera | Logout

Is it possible to adopt a process?

Asked 2012-05-09T16:05:46.603
26

Process A fork()s process B.

Process A dies and therefore init adopts B.

A watchdog creates process C.

Is it somehow possible for C to adopt B from init?


Update:

Or would it even be possible to have C adopt B directly (when A dies), if C were created prior to A's dead, without init becoming an intermediate parent of B?


Update-1:

Also I would appreciate any comments on why having the possiblity to adopt a process the way I described would be a bad thing or difficult to impossible to implement.


Update-2 - The use case (parent and children refer to process(es)):

I have an app using a parent to manage a whole bunch of children, which rely on the parent's managment facility. To do its job the parent relies on being notified by a child's termination, which is done via receiving the related SIGCHLD signal.

If the parent itself dies due some accident (including segfaulting) I need to restart the whole "family", as it's impossible now to trigger something on a child's termination (which also might due to a segfault).

In such a case I need to bring down all children and do a full system's restart.

A possible approach to avoid this situation, would be to have a spare-process in place which could take over the dead parent's role ... - if it could again receive the step children's SIGCHLD signals!

Edit
Report

1 Answer

8

No there is no way that you can enforce Reparenting in the way you have described.

answered 2012-05-09T16:13:21.740

Your Answer