Sujet : Re: Why does getppid() still return old parent pid after setsid()?
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.unix.programmerDate : 09. Nov 2024, 01:07:27
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vgm93v$3dkuq$4@dont-email.me>
References : 1 2
User-Agent : Pan/0.160 (Toresk; )
On Fri, 8 Nov 2024 15:30:21 -0000 (UTC), Lew Pitcher wrote:
So, while setsid(2) "creates a session and sets the process group ID"
for a process, it does not change the process' parent PID.
It is possible for the parent process to terminate before the child.
The child is then said to be “orphaned”. From this point, normally
getppid() will return 1, the PID of the init process.
However, on Linux, it is possible to specify an alternative “child
subreaper” process, via prctl()
<
https://manpages.debian.org/bookworm/manpages-dev/prctl.2.en.html>.
getppid() will then return the ID of this process.