diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-10-17 10:17:49 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-10-18 14:39:33 +0200 |
commit | a7a877697f07d764b12694316917aa1dc6ff64fb (patch) | |
tree | 3ef9778396fa0313cbea2bbc45275f7631da8fae /src/core/unit.c | |
parent | process-util: add pidref_get_comm() and rename get_process_comm() to pid_get_... (diff) | |
download | systemd-a7a877697f07d764b12694316917aa1dc6ff64fb.tar.xz systemd-a7a877697f07d764b12694316917aa1dc6ff64fb.zip |
pidref: add new pidref_is_self() helper
This simply checks if the specified PidRef refers to the process we are
running in.
(In case you wonder why this is not a static inline: to avoid cyclic
header inclusion problems between pidref.h + process-util.h)
Diffstat (limited to 'src/core/unit.c')
-rw-r--r-- | src/core/unit.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index 507d350e7e..4300f18d9b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -5949,7 +5949,7 @@ int unit_pid_attachable(Unit *u, PidRef *pid, sd_bus_error *error) { return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Process identifier is not valid."); /* Some extra safety check */ - if (pid->pid == 1 || pid->pid == getpid_cached()) + if (pid->pid == 1 || pidref_is_self(pid)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Process " PID_FMT " is a manager process, refusing.", pid->pid); /* Don't even begin to bother with kernel threads */ |