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.)
This commit is contained in:
Lennart Poettering
2023-09-09 14:03:31 +02:00
parent 1e1441d796
commit 3bda3f17fa
3 changed files with 175 additions and 0 deletions
+1
View File
@@ -65,6 +65,7 @@ basic_sources = files(
'path-lookup.c',
'path-util.c',
'percent-util.c',
'pidref.c',
'prioq.c',
'proc-cmdline.c',
'process-util.c',