summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2025-01-11 23:45:15 +0100
committerMike Yuan <me@yhndnzj.com>2025-01-11 23:47:52 +0100
commita342c71d360e083b3f6b06a64d852c4e3aceeef3 (patch)
treef4284748976258228268d9500b588bcb01b19e57 /src
parentmissing_syscall: require a bunch of syscalls below baseline (diff)
downloadsystemd-a342c71d360e083b3f6b06a64d852c4e3aceeef3.tar.xz
systemd-a342c71d360e083b3f6b06a64d852c4e3aceeef3.zip
sd-event: assign pid to event source at last also in sd_event_add_child_pidfd()
I.e. apply 54988a27b9d1487e1690f94b79031ef61edd6651 to sd_event_add_child_pidfd() too.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-event/sd-event.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index c1f1747fd0..563b7626fb 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -1727,17 +1727,12 @@ _public_ int sd_event_add_child_pidfd(
s->wakeup = WAKEUP_EVENT_SOURCE;
s->child.pidfd = pidfd;
- s->child.pid = pid;
s->child.options = options;
s->child.callback = callback;
s->child.pidfd_owned = false; /* If we got the pidfd passed in we don't own it by default (similar to the IO fd case) */
s->userdata = userdata;
s->enabled = SD_EVENT_ONESHOT;
- r = hashmap_put(e->child_sources, PID_TO_PTR(pid), s);
- if (r < 0)
- return r;
-
if (EVENT_SOURCE_WATCH_PIDFD(s)) {
/* We only want to watch for WEXITED */
r = source_child_pidfd_register(s, s->enabled);
@@ -1752,6 +1747,11 @@ _public_ int sd_event_add_child_pidfd(
e->need_process_child = true;
}
+ r = hashmap_put(e->child_sources, PID_TO_PTR(pid), s);
+ if (r < 0)
+ return r;
+
+ s->child.pid = pid;
e->n_online_child_sources++;
if (ret)