From 3d7ba61a7bfcc8273dbf354008970343e408ff81 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 16 Oct 2023 23:11:58 +0200 Subject: [PATCH] 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. --- src/basic/pidref.c | 3 +++ 1 file changed, 3 insertions(+) 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 */ -- 2.47.3