Reputation: 3993
If a process did fork
then child did setsid
, is there any way to tell that it was the child of the first process? Is there any way to kill such process together with its parent?
Upvotes: 2
Views: 221
Reputation: 25516
setsid
does not destroy the parent/child relation. So you still can get the children of a process, e. g. as described here (link us ubuntu specific, but this works for any other distribution).
The parent process always can keep track of its direct children easily, as fork returns their id (grand children gets more tricky...) and send a signal to any of its children on exiting (gracefully).
prctl(PR_SET_PDEATHSIG, <signal>)
(convenient way to make the children receive a signal, if parent dies), too, will survive a call to setsid.
Upvotes: 1