From 1d966345df6721dc1da257867a18a84f1d9f98d5 Mon Sep 17 00:00:00 2001 From: pcpa Date: Sat, 27 Sep 2014 16:04:16 -0300 Subject: [PATCH] su: print proper core dump message when killed An example is, in one terminal "sudo su -; echo $$", and in another terminal, "kill -9 $PID" (the pid of the su -). It should not print "(core dumped)", unless the kill signal specified so, e.g. kill -7 or kill -11. Signed-off-by: pcpa --- login-utils/su-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/login-utils/su-common.c b/login-utils/su-common.c index db72826214..eb3b844be0 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -363,10 +363,9 @@ create_watching_parent (void) { if (WIFSIGNALED (status)) { + fprintf (stderr, "%s%s\n", strsignal (WTERMSIG (status)), + WCOREDUMP (status) ? _(" (core dumped)") : ""); status = WTERMSIG (status) + 128; - if (WCOREDUMP (status)) - fprintf (stderr, _("%s (core dumped)\n"), - strsignal (WTERMSIG (status))); } else status = WEXITSTATUS (status); -- 2.47.3