summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2022-01-11 22:24:11 +0100
committerBenBE <BenBE@geshi.org>2022-01-11 22:56:27 +0100
commita0ad0697a8ebb69a183c44d5b812ac1c375c73e5 (patch)
tree030eccc72f3e2d251dce0fbb03a8ed6bb4309fa0
parenta133ffd8295302ea5fb0ba6f609e811adc7d1d9d (diff)
Always set SIGCHLD to default handling
The parent process of htop might have set SIGCHLD to ignore, which can be inherited by htop (Linux does this, OpenBSD resets to default). If SIGCHLD is ignored then waitpid returns -1 which is not properly handled by htop for lsof output. Proof of Concept (Linux): #include <signal.h> #include <unistd.h> int main(void) { char *arg[] = { "htop", NULL }; signal(SIGCHLD, SIG_IGN); execv("htop", arg); return 1; } If you run htop with ignored SIGCHLD then pressing "l" always fails, i.e. it is not possible to list open files even if lsof is installed.
-rw-r--r--CRT.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/CRT.c b/CRT.c
index 3a665496..583b6266 100644
--- a/CRT.c
+++ b/CRT.c
@@ -880,6 +880,7 @@ static void CRT_installSignalHandlers(void) {
sigaction (SIGSYS, &act, &old_sig_handler[SIGSYS]);
sigaction (SIGABRT, &act, &old_sig_handler[SIGABRT]);
+ signal(SIGCHLD, SIG_DFL);
signal(SIGINT, CRT_handleSIGTERM);
signal(SIGTERM, CRT_handleSIGTERM);
signal(SIGQUIT, CRT_handleSIGTERM);

© 2014-2024 Faster IT GmbH | imprint | privacy policy