keventd: drop SIGCHLD save/restore dance, libuev reaps for us

modprobe_load() and run_program() used to temporarily restore the
default SIGCHLD handler around fork+waitpid because the main loop set
SIGCHLD=SIG_IGN.  With the libuev conversion, sigchld_cb in keventd.c
handles reaping via signalfd -- and signalfd does not interfere with
synchronous waitpid(pid, ...) -- so the dance is dead code.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-08-16 22:03:33 +02:00
1 parent 0111dc2178
commit 9d5e646e46
2 files changed
+1 -23

No files matched your search

+1 -12
View File
@@ -782,13 +782,9 @@ static int pattern_match(const char *pat, const char *subject, pat_type_t type)
/* ----- program execution ------------------------------------------------ */ /* ----- program execution ------------------------------------------------ */
/* /* Fork and exec cmd via /bin/sh, capture stdout into result. */
* Fork and exec cmd via /bin/sh, capture stdout into result.
* Temporarily restores SIGCHLD (keventd uses SIG_IGN) so waitpid works.
*/
static int run_program(const char *cmd, char *result, size_t rlen) static int run_program(const char *cmd, char *result, size_t rlen)
{ {
struct sigaction sa_dfl, sa_old;
int pipefd[2]; int pipefd[2];
pid_t pid; pid_t pid;
int rc = -1; int rc = -1;
@@ -799,14 +795,8 @@ static int run_program(const char *cmd, char *result, size_t rlen)
if (pipe(pipefd) < 0) if (pipe(pipefd) < 0)
return -1; return -1;
sigemptyset(&sa_dfl.sa_mask);
sa_dfl.sa_flags = 0;
sa_dfl.sa_handler = SIG_DFL;
sigaction(SIGCHLD, &sa_dfl, &sa_old);
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
sigaction(SIGCHLD, &sa_old, NULL);
close(pipefd[0]); close(pipefd[0]);
close(pipefd[1]); close(pipefd[1]);
return -1; return -1;
@@ -838,7 +828,6 @@ static int run_program(const char *cmd, char *result, size_t rlen)
rc = WIFEXITED(status) ? WEXITSTATUS(status) : -1; rc = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
} }
sigaction(SIGCHLD, &sa_old, NULL);
return rc; return rc;
} }
-11
View File
@@ -1038,13 +1038,9 @@ fail:
* Synchronous: waits for modprobe to complete before returning so * Synchronous: waits for modprobe to complete before returning so
* that rules running after `kmod load` (e.g. IMPORT{builtin}=blkid * that rules running after `kmod load` (e.g. IMPORT{builtin}=blkid
* once the filesystem driver is in) see the post-load state. * once the filesystem driver is in) see the post-load state.
* keventd's main loop uses SIGCHLD=SIG_IGN to auto-reap stray
* children, so we temporarily restore the default handler here to
* make waitpid() observable.
*/ */
int modprobe_load(const char *modalias) int modprobe_load(const char *modalias)
{ {
struct sigaction sa_dfl, sa_old;
pid_t pid; pid_t pid;
int status = 0; int status = 0;
@@ -1053,15 +1049,9 @@ int modprobe_load(const char *modalias)
logit(LOG_DEBUG, "Loading module for %s", modalias); logit(LOG_DEBUG, "Loading module for %s", modalias);
sigemptyset(&sa_dfl.sa_mask);
sa_dfl.sa_flags = 0;
sa_dfl.sa_handler = SIG_DFL;
sigaction(SIGCHLD, &sa_dfl, &sa_old);
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
logit(LOG_ERR, "fork failed: %s", strerror(errno)); logit(LOG_ERR, "fork failed: %s", strerror(errno));
sigaction(SIGCHLD, &sa_old, NULL);
return -1; return -1;
} }
@@ -1072,7 +1062,6 @@ int modprobe_load(const char *modalias)
while (waitpid(pid, &status, 0) < 0 && errno == EINTR) while (waitpid(pid, &status, 0) < 0 && errno == EINTR)
; ;
sigaction(SIGCHLD, &sa_old, NULL);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
return -1; return -1;