[comp.unix.questions] Can I disown a child?

shj@ultra.com (Steve Jay) (04/02/91)

I want to fork a process & not have to worry about reaping it.  How
can I prevent the child from becoming a zombie when it quits?

I don't normally read this newsgroup, so please email responses directly
to me.

Thanks.

Steve Jay
shj@ultra.com  ...ames!ultra!shj
Ultra Network Technologies / 101 Dagget Drive / San Jose, CA 95134 / USA
(408) 922-0100 x130	"Home of the 1 Gigabit/Second network"

gwyn@smoke.brl.mil (Doug Gwyn) (04/03/91)

In article <1991Apr1.190700.2833@ultra.com> shj@ultra.com (Steve Jay) writes:
>I want to fork a process & not have to worry about reaping it.  How
>can I prevent the child from becoming a zombie when it quits?

The classical solution is to fork twice, with the intermediate parent
immediately terminating, so that the "grandchild" has no parent and
the "grandparent" continues about its business.  When an orphaned
child terminates, it is assigned PID #1 as its surrogate parent.
PID #1 is the "init" process that always exists and fairly soon will
wait() for a child, thus finally laying the deceased orphan to rest.

>I don't normally read this newsgroup, so please email responses directly
>to me.

Too bad, if you ask it here you should look here for the answer.