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 2e4a594221

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-01-04 00:00:00 -06:00 committed by Craig Small
parent 9e4c2cca39
commit 7db65421d0

View File

@ -48,6 +48,10 @@ char *myname;
/* just reports a crash */ /* just reports a crash */
static void signal_handler(int signo){ 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 */ if(signo==SIGPIPE) _exit(0); /* "ps | head" will cause this */
/* fprintf() is not reentrant, but we _exit() anyway */ /* fprintf() is not reentrant, but we _exit() anyway */
fprintf(stderr, fprintf(stderr,
@ -65,6 +69,9 @@ static void signal_handler(int signo){
default: default:
error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug")); error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug"));
signal(signo, SIG_DFL); /* allow core file creation */ signal(signo, SIG_DFL); /* allow core file creation */
sigemptyset(&ss);
sigaddset(&ss, signo);
sigprocmask(SIG_UNBLOCK, &ss, NULL);
kill(getpid(), signo); kill(getpid(), signo);
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }