From 1f01bd9a9f154ab786fcd9940f2e93da7c4c4da0 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sat, 4 Jan 2020 00:00:00 -0600 Subject: [PATCH] ps: for abnormal end allow core dumps (fix qualys bug) A Qualys audit patch, represented in the commit below, added the _exit() call to our abnormal signal handler. Unfortunately, that disabled the associated core dump. This patch restores expected behavior of those signals whose default produces a core dump file + termination. Reference(s): commit 7bd4f0b6d7e058197ccf4234f2a0bcc17550d0a6 Signed-off-by: Jim Warner --- ps/display.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ps/display.c b/ps/display.c index a7eee15e..bec23231 100644 --- a/ps/display.c +++ b/ps/display.c @@ -44,6 +44,10 @@ long Hertz; /* just reports a crash */ static void signal_handler(int signo){ + sigset_t ss; + + sigfillset(&ss); + sigprocmask(SIG_BLOCK, &ss, NULL); if(signo==SIGPIPE) _exit(0); /* "ps | head" will cause this */ /* fprintf() is not reentrant, but we _exit() anyway */ fprintf(stderr, @@ -61,6 +65,9 @@ static void signal_handler(int signo){ default: error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug")); signal(signo, SIG_DFL); /* allow core file creation */ + sigemptyset(&ss); + sigaddset(&ss, signo); + sigprocmask(SIG_UNBLOCK, &ss, NULL); kill(getpid(), signo); _exit(EXIT_FAILURE); }