mirror of https://github.com/xzeldon/htop.git
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.
This commit is contained in:
parent
a133ffd829
commit
a0ad0697a8
1
CRT.c
1
CRT.c
|
@ -880,6 +880,7 @@ static void CRT_installSignalHandlers(void) {
|
||||||
sigaction (SIGSYS, &act, &old_sig_handler[SIGSYS]);
|
sigaction (SIGSYS, &act, &old_sig_handler[SIGSYS]);
|
||||||
sigaction (SIGABRT, &act, &old_sig_handler[SIGABRT]);
|
sigaction (SIGABRT, &act, &old_sig_handler[SIGABRT]);
|
||||||
|
|
||||||
|
signal(SIGCHLD, SIG_DFL);
|
||||||
signal(SIGINT, CRT_handleSIGTERM);
|
signal(SIGINT, CRT_handleSIGTERM);
|
||||||
signal(SIGTERM, CRT_handleSIGTERM);
|
signal(SIGTERM, CRT_handleSIGTERM);
|
||||||
signal(SIGQUIT, CRT_handleSIGTERM);
|
signal(SIGQUIT, CRT_handleSIGTERM);
|
||||||
|
|
Loading…
Reference in New Issue