diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2022-01-11 22:24:11 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2022-01-11 22:56:27 +0100 |
commit | a0ad0697a8ebb69a183c44d5b812ac1c375c73e5 (patch) | |
tree | 030eccc72f3e2d251dce0fbb03a8ed6bb4309fa0 | |
parent | a133ffd8295302ea5fb0ba6f609e811adc7d1d9d (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.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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); |