Sujet : Re: Why does getppid() still return old parent pid after setsid()?
De : rweikusat (at) *nospam* talktalk.net (Rainer Weikusat)
Groupes : comp.unix.programmerDate : 11. Nov 2024, 16:53:44
Autres entêtes
Message-ID : <87frnxzrzr.fsf@doppelsaurus.mobileactivedefense.com>
References : 1
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Muttley@DastartdlyHQ.org writes:
I've tried this code on both MacOS and Linux yet the child process getppid()
still returns its original parent process instead of "1" for init which is
what I'd expect. Isn't setsid() supposed to completely detach the child or
have I misunderstood?
A session is a set of processes associated with a particular controlling
terminal, namely, that of the session leader (or no controlling terminal
if the session leader doesn't have one). setsid creates an unassociated
new session lead by the process which called it. It has no effect on
parent/ child relationships of processes.