diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-05-03 14:13:58 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-05-03 18:21:42 +0200 |
commit | 0de343187127f6a5a93602608812e60fc4092c9a (patch) | |
tree | af1d8c130a51efa6b0009d0ee47d3813eb97369d /src/libsystemd | |
parent | ca71b1d9669ee572ed122c627bf58a7b12ea7677 (diff) | |
download | systemd-0de343187127f6a5a93602608812e60fc4092c9a.tar.gz |
sd-daemon: add sd_pid_notify_barrier() call and use it in systemd-notify
Previously we'd honour --pid= from the main notification we send, but
not from the barrier. This is confusing at best. Let's fix that.
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/libsystemd.sym | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-daemon/sd-daemon.c | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym index 75c8f2225b..8b99d0a7aa 100644 --- a/src/libsystemd/libsystemd.sym +++ b/src/libsystemd/libsystemd.sym @@ -823,4 +823,5 @@ global: sd_event_source_set_memory_pressure_type; sd_event_source_set_memory_pressure_period; sd_event_trim_memory; + sd_pid_notify_barrier; } LIBSYSTEMD_253; diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index 34525b0a7b..8538b7ab82 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -601,14 +601,14 @@ finish: return r; } -_public_ int sd_notify_barrier(int unset_environment, uint64_t timeout) { +_public_ int sd_pid_notify_barrier(pid_t pid, int unset_environment, uint64_t timeout) { _cleanup_close_pair_ int pipe_fd[2] = PIPE_EBADF; int r; if (pipe2(pipe_fd, O_CLOEXEC) < 0) return -errno; - r = sd_pid_notify_with_fds(0, unset_environment, "BARRIER=1", &pipe_fd[1], 1); + r = sd_pid_notify_with_fds(pid, unset_environment, "BARRIER=1", &pipe_fd[1], 1); if (r <= 0) return r; @@ -623,6 +623,10 @@ _public_ int sd_notify_barrier(int unset_environment, uint64_t timeout) { return 1; } +_public_ int sd_notify_barrier(int unset_environment, uint64_t timeout) { + return sd_pid_notify_barrier(0, unset_environment, timeout); +} + _public_ int sd_pid_notify(pid_t pid, int unset_environment, const char *state) { return sd_pid_notify_with_fds(pid, unset_environment, state, NULL, 0); } |