]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: Remove unnecessary SIGCHLD blocking 39806/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 18 Dec 2025 09:33:40 +0000 (10:33 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 20 Dec 2025 14:50:47 +0000 (15:50 +0100)
Now that sd-event doesn't insist on blocking
SIGCHLD anymore when watching for process exit,
let's stop blocking SIGCHLD tree-wide where not
required anymore.

27 files changed:
src/home/homed-manager.c
src/home/homed.c
src/import/importd.c
src/libsystemd/sd-event/test-event.c
src/login/logind.c
src/machine/machined.c
src/mountfsd/mountfsd-manager.c
src/mountfsd/mountfsd.c
src/notify/notify.c
src/nsresourced/nsresourced-manager.c
src/nsresourced/nsresourced.c
src/portable/portabled.c
src/ptyfwd/ptyfwd-tool.c
src/shared/fork-notify.c
src/sysupdate/sysupdate.c
src/sysupdate/sysupdated.c
src/test/test-execute.c
src/test/test-mempress.c
src/test/test-notify-recv.c
src/udev/test-udev-rule-runner.c
src/udev/test-udev-spawn.c
src/udev/udev-manager.c
src/udev/udev-manager.h
src/udev/udev-spawn.c
src/userdb/userdbd-manager.c
src/userdb/userdbd.c
src/vmspawn/vmspawn.c

index fe5bd0c2b7719626895b085efca65665ad7c0202..ce4bedddc17f8a3f06a841f93869ca81b984e78e 100644 (file)
@@ -1157,7 +1157,7 @@ static int manager_listen_notify(Manager *m) {
 
         r = notify_socket_prepare_full(
                         m->event,
-                        SD_EVENT_PRIORITY_NORMAL - 5, /* Make sure we process sd_notify() before SIGCHLD for
+                        SD_EVENT_PRIORITY_NORMAL - 5, /* Make sure we process sd_notify() before child exit for
                                                        * any worker, so that we always know the error number
                                                        * of a client before it exits. */
                         on_notify_socket,
index 9aaabd5c19e51ab255c4700685ab4855683102e3..753aa95eb3f8f63b1371685fb1257f2813320518 100644 (file)
@@ -12,7 +12,6 @@
 #include "log.h"
 #include "main-func.h"
 #include "service-util.h"
-#include "signal-util.h"
 
 static int run(int argc, char *argv[]) {
         _cleanup_(manager_freep) Manager *m = NULL;
@@ -32,8 +31,6 @@ static int run(int argc, char *argv[]) {
 
         umask(0022);
 
-        assert_se(sigprocmask_many(SIG_BLOCK, /* ret_old_mask= */ NULL, SIGCHLD) >= 0);
-
         r = manager_new(&m);
         if (r < 0)
                 return log_error_errno(r, "Could not create manager: %m");
index 39d761683c3dc024d6aa2f77c7728ff691fcaf11..dea63e36e2573ed483fc55e1076cd4fc0646e627 100644 (file)
@@ -409,7 +409,7 @@ static int transfer_on_log(sd_event_source *s, int fd, uint32_t revents, void *u
                 log_error_errno(errno, "Failed to read log message: %m");
         if (l <= 0) {
                 /* EOF/read error. We just close the pipe here, and
-                 * close the watch, waiting for the SIGCHLD to arrive,
+                 * close the watch, waiting for the child to exit,
                  * before we do anything else. */
                 t->log_event_source = sd_event_source_unref(t->log_event_source);
                 return 0;
@@ -600,7 +600,7 @@ static int transfer_start(Transfer *t) {
         if (r < 0)
                 return r;
 
-        /* Make sure always process logging before SIGCHLD */
+        /* Make sure always process logging before child exit */
         r = sd_event_source_set_priority(t->log_event_source, SD_EVENT_PRIORITY_NORMAL -5);
         if (r < 0)
                 return r;
@@ -724,7 +724,7 @@ static int manager_new(RuntimeScope scope, Manager **ret) {
 
         r = notify_socket_prepare(
                         m->event,
-                        SD_EVENT_PRIORITY_NORMAL - 1, /* Make this processed before SIGCHLD. */
+                        SD_EVENT_PRIORITY_NORMAL - 1, /* Make this processed before child exit. */
                         manager_on_notify,
                         m,
                         &m->notify_socket_path);
@@ -2062,8 +2062,6 @@ static int run(int argc, char *argv[]) {
 
         umask(0022);
 
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
-
         r = manager_new(scope, &m);
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate manager object: %m");
index 648daf7c81d5b6b7ba6535baf49b580185cde1b8..20c0ac738589776eb6114753c9b9f0ab46289b65 100644 (file)
@@ -93,7 +93,7 @@ static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si,
 
         ASSERT_PTR_EQ(userdata, INT_TO_PTR('e'));
 
-        ASSERT_OK(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGUSR2));
+        ASSERT_OK(sigprocmask_many(SIG_BLOCK, NULL, SIGUSR2));
 
         ASSERT_OK_ERRNO(pid = fork());
 
@@ -568,8 +568,6 @@ TEST(pidfd) {
         int pidfd;
         pid_t pid, pid2;
 
-        ASSERT_OK(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD));
-
         ASSERT_OK_ERRNO(pid = fork());
         if (pid == 0)
                 /* child */
@@ -1001,8 +999,6 @@ static int child_handler_wnowait(sd_event_source *s, const siginfo_t *si, void *
 TEST(child_wnowait) {
         _cleanup_(sd_event_unrefp) sd_event *e = NULL;
 
-        ASSERT_OK(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD));
-
         ASSERT_OK(sd_event_default(&e));
 
         /* Fork a subprocess */
@@ -1034,8 +1030,6 @@ TEST(child_wnowait) {
 TEST(child_pidfd_wnowait) {
         _cleanup_(sd_event_unrefp) sd_event *e = NULL;
 
-        ASSERT_OK(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD));
-
         ASSERT_OK(sd_event_default(&e));
 
         /* Fork a subprocess */
index 8f16eeabb765fc8a127526d1ba169cff99253736..2b7984051e1975fd6f865b7d6e9235a0f82cbe83 100644 (file)
@@ -1372,8 +1372,6 @@ static int run(int argc, char *argv[]) {
         (void) mkdir_label("/run/systemd/users", 0755);
         (void) mkdir_label("/run/systemd/sessions", 0755);
 
-        assert_se(sigprocmask_many(SIG_BLOCK, /* ret_old_mask= */ NULL, SIGCHLD) >= 0);
-
         r = manager_new(&m);
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate manager object: %m");
index b972b182b6e07196881347aff379ac7a82d8b668..dfb01abea646cfaf8f83b447fbfbd169c4372d49 100644 (file)
@@ -366,8 +366,6 @@ static int run(int argc, char *argv[]) {
         if (scope == RUNTIME_SCOPE_SYSTEM)
                 (void) mkdir_label("/run/systemd/machines", 0755);
 
-        assert_se(sigprocmask_many(SIG_BLOCK, /* ret_old_mask= */ NULL, SIGCHLD) >= 0);
-
         r = manager_new(scope, &m);
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate manager object: %m");
index 5714f7c8c5383ba3b629ba5c96a79276b9a2f58c..1cbe6c182ca525f72650431bc549c326eddf7dee 100644 (file)
@@ -51,7 +51,7 @@ static int on_worker_exit(sd_event_source *s, const siginfo_t *si, void *userdat
         else if (si->si_code == CLD_DUMPED)
                 log_warning("Worker " PID_FMT " dumped core by signal %s, ignoring.", si->si_pid, signal_to_string(si->si_status));
         else
-                log_warning("Got unexpected exit code via SIGCHLD, ignoring.");
+                log_warning("Got unexpected exit code from child, ignoring.");
 
         (void) start_workers(m, /* explicit_request= */ false); /* Fill up workers again if we fell below the low watermark */
         return 0;
index 6894c31b3f709b21d3e02d470e059e1f48c319d7..e34eb181f2dd5ba65dcb118efe714704a87b4e7f 100644 (file)
@@ -8,7 +8,6 @@
 #include "log.h"
 #include "main-func.h"
 #include "mountfsd-manager.h"
-#include "signal-util.h"
 
 static int run(int argc, char *argv[]) {
         _unused_ _cleanup_(notify_on_cleanup) const char *notify_stop = NULL;
@@ -22,8 +21,6 @@ static int run(int argc, char *argv[]) {
         if (argc != 1)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments.");
 
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
-
         r = manager_new(&m);
         if (r < 0)
                 return log_error_errno(r, "Could not create manager: %m");
index 270d1b1f9ad5675d0dda136edbcc015127cf224f..6a39147f99e1cf7718089ea7ffb0fa65f005bca2 100644 (file)
@@ -506,9 +506,10 @@ static int action_fork(char *const *_command) {
         _cleanup_free_ char *addr_string = NULL;
         r = notify_socket_prepare(
                         event,
-                        SD_EVENT_PRIORITY_NORMAL - 10, /* If we receive both the sd_notify() message and a
-                                                        * SIGCHLD always process sd_notify() first, it's the
-                                                        * more interesting, "positive" information. */
+                        SD_EVENT_PRIORITY_NORMAL - 10, /* If we receive both the sd_notify() message and
+                                                        * child exit notification, always process sd_notify()
+                                                        * first, it's the more interesting, "positive"
+                                                        * information. */
                         on_notify_socket,
                         &child,
                         &addr_string);
@@ -541,14 +542,12 @@ static int action_fork(char *const *_command) {
                 fflush(stdout);
         }
 
-        BLOCK_SIGNALS(SIGCHLD);
-
         _cleanup_(sd_event_source_disable_unrefp) sd_event_source *child_event_source = NULL;
         r = event_add_child_pidref(event, &child_event_source, &child, WEXITED, on_child, /* userdata= */ NULL);
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate child source: %m");
 
-        /* Handle SIGCHLD before propagating the other signals below */
+        /* Handle child exit before propagating the other signals below */
         r = sd_event_source_set_priority(child_event_source, SD_EVENT_PRIORITY_NORMAL - 5);
         if (r < 0)
                 return log_error_errno(r, "Failed to change child event source priority: %m");
index b09639bb49b79c66792805ee0a24821fdcb0b894..59cdce6cb06a3ebd752f1feb576076d9517f9237 100644 (file)
@@ -58,7 +58,7 @@ static int on_worker_exit(sd_event_source *s, const siginfo_t *si, void *userdat
         else if (si->si_code == CLD_DUMPED)
                 log_warning("Worker " PID_FMT " dumped core by signal %s, ignoring.", si->si_pid, signal_to_string(si->si_status));
         else
-                log_warning("Got unexpected exit code via SIGCHLD, ignoring.");
+                log_warning("Got unexpected exit code from child, ignoring.");
 
         (void) start_workers(m, /* explicit_request= */ false); /* Fill up workers again if we fell below the low watermark */
         return 0;
index 455ee70705b54ee390e3a550b754274a974c92d4..c261f3c550f2aced6ab6d3f6ce9af918bd3c3f69 100644 (file)
@@ -9,7 +9,6 @@
 #include "log.h"
 #include "main-func.h"
 #include "nsresourced-manager.h"
-#include "signal-util.h"
 
 static int run(int argc, char *argv[]) {
         _cleanup_(manager_freep) Manager *m = NULL;
@@ -25,8 +24,6 @@ static int run(int argc, char *argv[]) {
         if (setenv("SYSTEMD_BYPASS_USERDB", "io.systemd.NamespaceResource", 1) < 0)
                 return log_error_errno(errno, "Failed to set $SYSTEMD_BYPASS_USERDB: %m");
 
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
-
         r = manager_new(&m);
         if (r < 0)
                 return log_error_errno(r, "Could not create manager: %m");
index 4059de01ed9561ac7baba928b2b5195ad4e2ce5b..e5e6eb9810acfcffa117376151a077a110d7fd99 100644 (file)
@@ -143,8 +143,6 @@ static int run(int argc, char *argv[]) {
         if (argc != 1)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments.");
 
-        assert_se(sigprocmask_many(SIG_BLOCK, /* ret_old_mask= */ NULL, SIGCHLD) >= 0);
-
         r = manager_new(&m);
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate manager object: %m");
index e7b5e03e15ea6615bf2d1df155c22956626c48b9..519bd3641d514c955e4ff2945ab289a9be2b1d42 100644 (file)
@@ -14,7 +14,6 @@
 #include "pretty-print.h"
 #include "process-util.h"
 #include "ptyfwd.h"
-#include "signal-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
@@ -156,8 +155,6 @@ static int run(int argc, char *argv[]) {
 
         log_setup();
 
-        assert_se(sigprocmask_many(SIG_BLOCK, /* ret_old_mask= */ NULL, SIGCHLD) >= 0);
-
         r = parse_argv(argc, argv);
         if (r <= 0)
                 return r;
index 424908ac3edcc0082a5ff9eed8e3c6522f769436..6f87a2fdce2b296991bce9bcd7cccbdd39bc8598 100644 (file)
@@ -35,7 +35,7 @@ static int on_child_exit(sd_event_source *s, const siginfo_t *si, void *userdata
         else if (si->si_code == CLD_DUMPED)
                 log_debug("Child process " PID_FMT " dumped core by signal %s, ignoring.", si->si_pid, signal_to_string(si->si_status));
         else
-                log_debug("Got unexpected exit code %i via SIGCHLD, ignoring.", si->si_code);
+                log_debug("Got unexpected exit code %i from child, ignoring.", si->si_code);
 
         /* And let's then fail the whole thing, because regardless what the exit status of the child is
          * (i.e. even if successful), if it exits before sending READY=1 something is wrong. */
@@ -106,7 +106,7 @@ int fork_notify(char * const *argv, PidRef *ret_pidref) {
         _cleanup_free_ char *addr_string = NULL;
         r = notify_socket_prepare_full(
                         event,
-                        SD_EVENT_PRIORITY_NORMAL-10, /* We want the notification message from the child before the SIGCHLD */
+                        SD_EVENT_PRIORITY_NORMAL-10, /* We want the notification message from the child before the child exit */
                         on_child_notify,
                         &child,
                         /* accept_fds= */ false,
@@ -124,8 +124,6 @@ int fork_notify(char * const *argv, PidRef *ret_pidref) {
                 log_debug("Invoking '%s' as child.", strnull(l));
         }
 
-        BLOCK_SIGNALS(SIGCHLD);
-
         r = pidref_safe_fork_full(
                         "(fork-notify)",
                         (const int[3]) { -EBADF, STDOUT_FILENO, STDERR_FILENO },
index 9816dd15b65e0245151e378f8e19c483892c715f..de3a9d2c485281111cbb481a24112d62794b576f 100644 (file)
@@ -23,7 +23,6 @@
 #include "path-util.h"
 #include "pretty-print.h"
 #include "set.h"
-#include "signal-util.h"
 #include "sort-util.h"
 #include "specifier.h"
 #include "string-util.h"
@@ -1877,9 +1876,6 @@ static int run(int argc, char *argv[]) {
         if (r <= 0)
                 return r;
 
-        /* SIGCHLD signal must be blocked for sd_event_add_child to work */
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
-
         return sysupdate_main(argc, argv);
 }
 
index 271f49c16b3d89248bb4766a3b3b94f3f0198a8f..a9740ee85423729b48750ac863dff44cef8c1677 100644 (file)
@@ -1738,7 +1738,7 @@ static int manager_new(Manager **ret) {
 
         r = notify_socket_prepare(
                         m->event,
-                        SD_EVENT_PRIORITY_NORMAL - 1, /* Make this processed before SIGCHLD. */
+                        SD_EVENT_PRIORITY_NORMAL - 1, /* Make this processed before worker exit. */
                         manager_on_notify,
                         m,
                         &m->notify_socket_path);
@@ -2078,9 +2078,6 @@ static int run(int argc, char *argv[]) {
 
         umask(0022);
 
-        /* SIGCHLD signal must be blocked for sd_event_add_child to work */
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
-
         r = manager_new(&m);
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate manager object: %m");
index 6c05b3e6a7e6de57ec3a2c6432019a02843726f5..1c787757424aa61d8f7ad76d0f9bfade1ada135f 100644 (file)
@@ -680,7 +680,7 @@ static int on_spawn_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
         return 1;
 }
 
-static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
+static int on_spawn_exit(sd_event_source *s, const siginfo_t *si, void *userdata) {
         int ret = -EIO;
 
         ASSERT_NOT_NULL(si);
@@ -706,8 +706,6 @@ static int find_libraries(const char *exec, char ***ret) {
         ASSERT_NOT_NULL(exec);
         ASSERT_NOT_NULL(ret);
 
-        ASSERT_OK(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD));
-
         ASSERT_OK_ERRNO(pipe2(outpipe, O_NONBLOCK|O_CLOEXEC));
         ASSERT_OK_ERRNO(pipe2(errpipe, O_NONBLOCK|O_CLOEXEC));
 
@@ -732,8 +730,8 @@ static int find_libraries(const char *exec, char ***ret) {
         ASSERT_OK(sd_event_source_set_enabled(stdout_source, SD_EVENT_ONESHOT));
         ASSERT_OK(sd_event_add_io(e, &stderr_source, errpipe[0], EPOLLIN, on_spawn_io, NULL));
         ASSERT_OK(sd_event_source_set_enabled(stderr_source, SD_EVENT_ONESHOT));
-        ASSERT_OK(sd_event_add_child(e, &sigchld_source, pid, WEXITED, on_spawn_sigchld, NULL));
-        /* SIGCHLD should be processed after IO is complete */
+        ASSERT_OK(sd_event_add_child(e, &sigchld_source, pid, WEXITED, on_spawn_exit, NULL));
+        /* Child exit should be processed after IO is complete */
         ASSERT_OK(sd_event_source_set_priority(sigchld_source, SD_EVENT_PRIORITY_NORMAL + 1));
 
         ASSERT_OK(sd_event_loop(e));
index 98db7f0e0281cca57dc1b31059e7e30ffc04506a..55cbc6e432c9e3d689c68463671162c7765b7f9b 100644 (file)
@@ -234,7 +234,6 @@ TEST(real_pressure) {
                 _exit(EXIT_SUCCESS);
         }
 
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
         assert_se(sd_event_add_child(e, &cs, pid, WEXITED, real_pressure_child_callback, NULL) >= 0);
         assert_se(sd_event_source_set_child_process_own(cs, true) >= 0);
 
index 5be0b82bf8d1d169b2a71749777a1160ba28013b..700118922f7efc93aa2e19928f503e9c3137945e 100644 (file)
@@ -90,8 +90,6 @@ TEST(notify_socket_prepare) {
         _cleanup_free_ char *path = NULL;
         ASSERT_OK(notify_socket_prepare_full(e, SD_EVENT_PRIORITY_NORMAL - 10, on_recv, &c, true, &path, NULL));
 
-        ASSERT_OK(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD));
-
         ASSERT_OK(r = pidref_safe_fork("(test-notify-recv-child)", FORK_DEATHSIG_SIGTERM|FORK_LOG, &c.pidref));
         if (r == 0) {
                 ASSERT_OK_ERRNO(setenv("NOTIFY_SOCKET", path, /* overwrite= */ true));
index 7a516096906f3a0f0f83272fc4f27dd200eaf9e5..34755b1f8b3a79f3309251c26a11a329dbba28cc 100644 (file)
@@ -143,7 +143,7 @@ static int run(int argc, char *argv[]) {
 
         assert_se(event = udev_event_new(dev, NULL, EVENT_TEST_RULE_RUNNER));
 
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, SIGHUP, SIGCHLD) >= 0);
+        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, SIGHUP) >= 0);
 
         /* do what devtmpfs usually provides us */
         if (sd_device_get_devname(dev, &devname) >= 0) {
index 73cfe7abc260427f402ac84e99f38fe80eafa1be..ab8a218c75f44b3c40fc794cb4fd70f39d88d07e 100644 (file)
@@ -7,7 +7,6 @@
 #include "alloc-util.h"
 #include "mountpoint-util.h"
 #include "path-util.h"
-#include "signal-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "tests.h"
@@ -104,8 +103,6 @@ int main(int argc, char *argv[]) {
 
         test_setup_logging(LOG_DEBUG);
 
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
-
         test_event_spawn_cat(true, SIZE_MAX);
         test_event_spawn_cat(false, SIZE_MAX);
         test_event_spawn_cat(true, 5);
index 8505bcdf266601fb3f79d2b9b013679772fecd51..11de3b9f9f3acfcec9aa30a3465f9b1bb3d5bf58 100644 (file)
@@ -390,7 +390,7 @@ void manager_revert(Manager *manager) {
         manager_kill_workers(manager, SIGTERM);
 }
 
-static int on_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
+static int on_worker_exit(sd_event_source *s, const siginfo_t *si, void *userdata) {
         _cleanup_(worker_freep) Worker *worker = ASSERT_PTR(userdata);
         sd_device *dev = worker->event ? ASSERT_PTR(worker->event->dev) : NULL;
 
@@ -452,11 +452,11 @@ static int worker_new(Worker **ret, Manager *manager, sd_device_monitor *worker_
         if (r < 0)
                 return r;
 
-        r = event_add_child_pidref(manager->event, &worker->child_event_source, &worker->pidref, WEXITED, on_sigchld, worker);
+        r = event_add_child_pidref(manager->event, &worker->child_event_source, &worker->pidref, WEXITED, on_worker_exit, worker);
         if (r < 0)
                 return r;
 
-        r = sd_event_source_set_priority(worker->child_event_source, EVENT_PRIORITY_WORKER_SIGCHLD);
+        r = sd_event_source_set_priority(worker->child_event_source, EVENT_PRIORITY_WORKER_EXIT);
         if (r < 0)
                 return r;
 
@@ -1363,9 +1363,6 @@ static int manager_setup_event(Manager *manager) {
 
         assert(manager);
 
-        /* block SIGCHLD for listening child events. */
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
-
         r = sd_event_default(&e);
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate event loop: %m");
index 9bafe24f280c8ce8e442b0feea0ec5f0b73d75b0..e0160e237ca673ca6b283279541b70bdc7e1c9c8 100644 (file)
 /* This must have a higher priority than the worker notification, to make IN_IGNORED event received earlier
  * than notifications about requests of adding/removing inotify watches. */
 #define EVENT_PRIORITY_INOTIFY_WATCH  (SD_EVENT_PRIORITY_NORMAL - 4)
-/* This must have a higher priority than the worker SIGCHLD event, to make notifications about completions of
- * processing events received before SIGCHLD. */
+/* This must have a higher priority than the worker exit event, to make notifications about completions of
+ * processing events received before exit. */
 #define EVENT_PRIORITY_WORKER_NOTIFY  (SD_EVENT_PRIORITY_NORMAL - 3)
 /* This should have a higher priority than timer events about killing long running worker processes or idle
  * worker processes. */
-#define EVENT_PRIORITY_WORKER_SIGCHLD (SD_EVENT_PRIORITY_NORMAL - 2)
-/* As said in the above, this should have a lower proority than the SIGCHLD event source. */
+#define EVENT_PRIORITY_WORKER_EXIT    (SD_EVENT_PRIORITY_NORMAL - 2)
+/* As said in the above, this should have a lower proority than the exit event source. */
 #define EVENT_PRIORITY_WORKER_TIMER   (SD_EVENT_PRIORITY_NORMAL - 1)
 /* This should have a lower priority than most event sources, but let's process earlier than varlink and the
  * legacy control socket. */
index 88ac5de350589876941bd739db17789f935da38c..d2ec715e990f2747c7480b042429532cca8495ad 100644 (file)
@@ -146,7 +146,7 @@ static int on_spawn_timeout_warning(sd_event_source *s, uint64_t usec, void *use
         return 1;
 }
 
-static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
+static int on_spawn_exit(sd_event_source *s, const siginfo_t *si, void *userdata) {
         Spawn *spawn = ASSERT_PTR(userdata);
         int ret = -EIO;
 
@@ -175,7 +175,7 @@ static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userd
 
 static int spawn_wait(Spawn *spawn) {
         _cleanup_(sd_event_unrefp) sd_event *e = NULL;
-        _cleanup_(sd_event_source_disable_unrefp) sd_event_source *sigchld_source = NULL;
+        _cleanup_(sd_event_source_disable_unrefp) sd_event_source *child_source = NULL;
         _cleanup_(sd_event_source_disable_unrefp) sd_event_source *stdout_source = NULL;
         _cleanup_(sd_event_source_disable_unrefp) sd_event_source *stderr_source = NULL;
         int r;
@@ -214,11 +214,12 @@ static int spawn_wait(Spawn *spawn) {
                         return log_device_debug_errno(spawn->device, r, "Failed to create stderr event source: %m");
         }
 
-        r = event_add_child_pidref(e, &sigchld_source, &spawn->pidref, WEXITED, on_spawn_sigchld, spawn);
+        r = event_add_child_pidref(e, &child_source, &spawn->pidref, WEXITED, on_spawn_exit, spawn);
         if (r < 0)
                 return log_device_debug_errno(spawn->device, r, "Failed to create sigchild event source: %m");
-        /* SIGCHLD should be processed after IO is complete */
-        r = sd_event_source_set_priority(sigchld_source, SD_EVENT_PRIORITY_NORMAL + 1);
+
+        /* Child exit should be processed after IO is complete */
+        r = sd_event_source_set_priority(child_source, SD_EVENT_PRIORITY_NORMAL + 1);
         if (r < 0)
                 return log_device_debug_errno(spawn->device, r, "Failed to set priority to sigchild event source: %m");
 
index b3b7acec581ab6c751e1a0cc23df95d69a78ad6c..7696222510409f6826e7a13903864e68194a1f73 100644 (file)
@@ -48,7 +48,7 @@ static int on_worker_exit(sd_event_source *s, const siginfo_t *si, void *userdat
         else if (si->si_code == CLD_DUMPED)
                 log_warning("Worker " PID_FMT " dumped core by signal %s, ignoring.", si->si_pid, signal_to_string(si->si_status));
         else
-                log_warning("Can't handle SIGCHLD of this type");
+                log_warning("Can't handle exit code of this type");
 
         (void) start_workers(m, /* explicit_request= */ false); /* Fill up workers again if we fell below the low watermark */
         return 0;
index f3f4d516b66111799e328d7150e69916b2836566..f5a5eece8cdba1dd121462341eb38ed61a5ec045 100644 (file)
@@ -8,7 +8,6 @@
 #include "daemon-util.h"
 #include "log.h"
 #include "main-func.h"
-#include "signal-util.h"
 #include "userdbd-manager.h"
 
 /* This service offers two Varlink services, both implementing io.systemd.UserDatabase:
@@ -39,8 +38,6 @@ static int run(int argc, char *argv[]) {
         if (setenv("SYSTEMD_BYPASS_USERDB", "io.systemd.NameServiceSwitch:io.systemd.Multiplexer:io.systemd.DropIn", 1) < 0)
                 return log_error_errno(errno, "Failed to set $SYSTEMD_BYPASS_USERDB: %m");
 
-        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD) >= 0);
-
         r = manager_new(&m);
         if (r < 0)
                 return log_error_errno(r, "Could not create manager: %m");
index 52ed833948a0e623adfa65b59422fe0dc9e9dbca..69ea071a8190f123580f8ccf1c15c8db16ed6602 100644 (file)
@@ -1085,7 +1085,7 @@ static int on_child_exit(sd_event_source *s, const siginfo_t *si, void *userdata
                                       si->si_pid, signal_to_string(si->si_status));
         else
                 ret = log_error_errno(SYNTHETIC_ERRNO(EPROTO),
-                                      "Got unexpected exit code %i via SIGCHLD,",
+                                      "Got unexpected exit code %i from child,",
                                       si->si_code);
 
         /* Regardless of whether the main qemu process or an auxiliary process died, let's exit either way
@@ -2288,8 +2288,6 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
                         return r;
         }
 
-        assert_se(sigprocmask_many(SIG_BLOCK, /* ret_old_mask= */ NULL, SIGCHLD) >= 0);
-
         _cleanup_(sd_event_unrefp) sd_event *event = NULL;
         r = sd_event_new(&event);
         if (r < 0)
@@ -2719,8 +2717,6 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
                 log_debug("Executing: %s", joined);
         }
 
-        assert_se(sigprocmask_many(SIG_BLOCK, /* ret_old_mask= */ NULL, SIGCHLD) >= 0);
-
         _cleanup_(pidref_done) PidRef child_pidref = PIDREF_NULL;
         r = pidref_safe_fork_full(
                         qemu_binary,