]> git.ipfire.org Git - thirdparty/systemd.git/commit
pidref: add structure that can reference a pid via both pidfd and pid_t
authorLennart Poettering <lennart@poettering.net>
Sat, 9 Sep 2023 07:29:27 +0000 (09:29 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 9 Sep 2023 12:03:31 +0000 (14:03 +0200)
commit3bda3f17fa84557eeb28fa7c330cbd3a3f876d47
treed26b356da03d01f859f2dc8bbb7fc22ddb92eb88
parent1e1441d796e30350e56cbcbf06e54312188e11b5
pidref: add structure that can reference a pid via both pidfd and pid_t

Let's start with the conversion of PID 1 to pidfds. Let's add a simple
structure with just two fields that can be used to maintain a reference
to arbitrary processes via both pid_t and pidfd.

This is an embeddable struct, to keep it in line with where we
previously used a pid_t directly to track a process.

Of course, since this might contain an fd on systems where we have pidfd
this structure has a proper lifecycle.

(Note that this is quite different from sd_event_add_child() event
source objects as that one is only for child processes and collects
process results, while this infra is much simpler and more generic and
can be used to reference any process, anywhere in the tree.)
src/basic/meson.build
src/basic/pidref.c [new file with mode: 0644]
src/basic/pidref.h [new file with mode: 0644]