]> git.ipfire.org Git - thirdparty/systemd.git/commit
process-util: add pidref_safe_fork() helper
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Nov 2023 17:07:44 +0000 (18:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 2 Jan 2024 16:57:34 +0000 (17:57 +0100)
commitf17132260f36e3db863afcb8bbbbec7ebd49bfb1
tree02d835929ce5c2b98d9b32386f7a7a49e1f9cd9a
parenta3f3243613b01903f5850a250c793d48d16ebb95
process-util: add pidref_safe_fork() helper

This combines safe_fork() with pidref_set_pid().

Eventually we really should switch this to use CLONE_PIDFD, but as that
is not wrapped by glibc yet, it's hard. But this is not crucial anyway,
as a child we just forked off can always safely be referenced also by
PID, given the reaping is under our own control.

A simple test case is added in a follow-up commit.
src/basic/process-util.c
src/basic/process-util.h