Deutsch   English   Français   Italiano  
<vgm93v$3dkuq$4@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.unix.programmer
Subject: Re: Why does getppid() still return old parent pid after setsid()?
Date: Sat, 9 Nov 2024 00:07:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <vgm93v$3dkuq$4@dont-email.me>
References: <vgl8h1$385vs$1@dont-email.me> <vglaqd$37mab$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 09 Nov 2024 01:07:27 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2144ffc59d8cce2fe73ad947016f3118";
	logging-data="3593178"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+P6X14fE9cvxy9ECb0UU4k"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:IIXGThANKDe/442L/sY6xhV5kCs=
Bytes: 1591

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.