From: Lennart Poettering Date: Mon, 16 Oct 2023 21:11:58 +0000 (+0200) Subject: pidref: we never have to verify PID 1 X-Git-Tag: v255-rc1~209^2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d7ba61a7bfcc8273dbf354008970343e408ff81;p=thirdparty%2Fsystemd.git pidref: we never have to verify PID 1 The process exists as long as the kernel/userns exists at all, hence we don't have to verify a pidfd to it. --- diff --git a/src/basic/pidref.c b/src/basic/pidref.c index db58a3d809d..3e37cce0ccd 100644 --- a/src/basic/pidref.c +++ b/src/basic/pidref.c @@ -250,6 +250,9 @@ int pidref_verify(const PidRef *pidref) { if (!pidref_is_set(pidref)) return -ESRCH; + if (pidref->pid == 1) + return 1; /* PID 1 can never go away, hence never be recycled to a different process → return 1 */ + if (pidref->fd < 0) return 0; /* If we don't have a pidfd we cannot validate it, hence we assume it's all OK → return 0 */