From f62eeeb2582889e5aeed1f8acca826bac272f4d8 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 2 Feb 2026 20:07:35 +0100 Subject: [PATCH] lib/pager: Set SIGCHLD to default handling If SIGCHLD is ignored, then waitpid might return an error if child process is already terminated, since zombie process generation would be blocked. Signed-off-by: Tobias Stoeckmann --- lib/pager.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pager.c b/lib/pager.c index 9cbf6383f..de4c2113c 100644 --- a/lib/pager.c +++ b/lib/pager.c @@ -35,6 +35,7 @@ struct child_process { int org_err; int org_out; + struct sigaction orig_sigchld; struct sigaction orig_sigint; struct sigaction orig_sighup; struct sigaction orig_sigterm; @@ -186,6 +187,12 @@ static void __setup_pager(void) pager_process.argv = pager_argv; pager_process.in = -1; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_DFL; + + /* this makes sure that waitpid works as expected */ + sigaction(SIGCHLD, &sa, &pager_process.orig_sigchld); + if (start_command(&pager_process)) return; @@ -198,7 +205,6 @@ static void __setup_pager(void) } close(pager_process.in); - memset(&sa, 0, sizeof(sa)); sa.sa_handler = wait_for_pager_signal; /* this makes sure that the parent terminates after the pager */ @@ -251,6 +257,7 @@ void pager_close(void) close(pager_process.org_err); /* restore original signal settings */ + sigaction(SIGCHLD, &pager_process.orig_sigchld, NULL); sigaction(SIGINT, &pager_process.orig_sigint, NULL); sigaction(SIGHUP, &pager_process.orig_sighup, NULL); sigaction(SIGTERM, &pager_process.orig_sigterm, NULL); -- 2.47.3