Sujet : Re: Why does getppid() still return old parent pid after setsid()?
De : geoff (at) *nospam* clare.See-My-Signature.invalid (Geoff Clare)
Groupes : comp.unix.programmerDate : 12. Nov 2024, 14:39:25
Autres entêtes
Message-ID : <dd2c0l-saq.ln1@ID-313840.user.individual.net>
References : 1
User-Agent : Pan/0.154 (Izium; 517acf4)
Muttley wrote:
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?
As others have pointed out, you have misunderstood, but I don't
think anyone has quoted a relevant bit of POSIX in the definition
of "Parent Process ID" (XBD 3.253 in POSIX.1-2024):
The parent process ID of a process is the process ID of its
creator, for the lifetime of the creator. After the creator's
lifetime has ended, the parent process ID is the process ID of an
implementation-defined system process.
-- Geoff Clare <netnews@gclare.org.uk>