ren
ren

Reputation: 3993

is there a way to tell if a process is a child if it did fork and then setsid

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

Answers (1)

Aconcagua
Aconcagua

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

Related Questions