From: Mike Yuan Date: Tue, 16 Dec 2025 01:07:22 +0000 (+0100) Subject: core/unit: add unit_fork_helper_process_full() that takes ForkFlags X-Git-Tag: v259~7^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f397d592217f9501c534bf2a36ed107c206bac4;p=thirdparty%2Fsystemd.git core/unit: add unit_fork_helper_process_full() that takes ForkFlags --- diff --git a/src/basic/basic-forward.h b/src/basic/basic-forward.h index 0f8c3ea06c8..d26cc5fe9b2 100644 --- a/src/basic/basic-forward.h +++ b/src/basic/basic-forward.h @@ -86,6 +86,7 @@ typedef enum CGroupFlags CGroupFlags; typedef enum CGroupMask CGroupMask; typedef enum ChaseFlags ChaseFlags; typedef enum ExtractFlags ExtractFlags; +typedef enum ForkFlags ForkFlags; typedef enum Glyph Glyph; typedef enum ImageClass ImageClass; typedef enum JobMode JobMode; diff --git a/src/core/unit.c b/src/core/unit.c index f37b12ac622..7161c1cb6c4 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -5539,12 +5539,13 @@ int unit_set_exec_params(Unit *u, ExecParameters *p) { return 0; } -int unit_fork_helper_process(Unit *u, const char *name, bool into_cgroup, PidRef *ret) { +int unit_fork_helper_process_full(Unit *u, const char *name, bool into_cgroup, ForkFlags flags, PidRef *ret) { CGroupRuntime *crt = NULL; pid_t pid; int r; assert(u); + assert((flags & (FORK_RESET_SIGNALS|FORK_DETACH|FORK_WAIT)) == 0); /* these don't really make sense for manager */ assert(ret); /* Forks off a helper process and makes sure it is a member of the unit's cgroup, if configured to @@ -5559,7 +5560,7 @@ int unit_fork_helper_process(Unit *u, const char *name, bool into_cgroup, PidRef crt = unit_get_cgroup_runtime(u); } - r = safe_fork(name, FORK_REOPEN_LOG|FORK_DEATHSIG_SIGTERM, &pid); + r = safe_fork(name, FORK_REOPEN_LOG|FORK_DEATHSIG_SIGTERM|flags, &pid); if (r < 0) return r; if (r > 0) { @@ -5592,6 +5593,10 @@ int unit_fork_helper_process(Unit *u, const char *name, bool into_cgroup, PidRef return 0; } +int unit_fork_helper_process(Unit *u, const char *name, bool into_cgroup, PidRef *ret) { + return unit_fork_helper_process_full(u, name, into_cgroup, /* flags = */ 0, ret); +} + int unit_fork_and_watch_rm_rf(Unit *u, char **paths, PidRef *ret_pid) { _cleanup_(pidref_done) PidRef pid = PIDREF_NULL; int r; diff --git a/src/core/unit.h b/src/core/unit.h index b3e0f95e996..dc546116f99 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -1005,6 +1005,7 @@ int unit_acquire_invocation_id(Unit *u); int unit_set_exec_params(Unit *u, ExecParameters *p); +int unit_fork_helper_process_full(Unit *u, const char *name, bool into_cgroup, ForkFlags flags, PidRef *ret); int unit_fork_helper_process(Unit *u, const char *name, bool into_cgroup, PidRef *ret); int unit_fork_and_watch_rm_rf(Unit *u, char **paths, PidRef *ret);