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);
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)