From a0ad0697a8ebb69a183c44d5b812ac1c375c73e5 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Tue, 11 Jan 2022 22:24:11 +0100 Subject: 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 #include 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. --- CRT.c | 1 + 1 file changed, 1 insertion(+) 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); -- cgit v1.2.3