Re: segfault message supressed with su -c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You'll need to key on WTERMSIG (status).
"Segmentation fault" will not always be appropriate.
You'll get a core just with Ctrl-\ (SIGQUIT) too for example.
Something along the lines of:

"%s (core dumped)", strsignal (WTERMSIG (status))

cheers,
Pádraig.
I've redone the patch to reflect your proposition :) .
Cheers,
  Ondrej.

From 65e73591fce2fa961bf6de1cbc934f6aa7a22745 Mon Sep 17 00:00:00 2001
From: Ondrej Oprala <ooprala@xxxxxxxxxx>
Date: Tue, 11 Sep 2012 16:39:17 +0200
Subject: [PATCH] su: add segmentation fault reporting of the child process
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Child processes that ended with segmentation fault previously
indicated this with return status only. The report is now more
verbose if core dump is allowed.

Improved-by: Pádraig Brady.
---
 login-utils/su-common.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index 23ad57d..2749303 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -300,7 +300,12 @@ create_watching_parent (void)
 	}
       if (pid != (pid_t)-1)
 	if (WIFSIGNALED (status))
-	  status = WTERMSIG (status) + 128;
+	  {
+	    status = WTERMSIG (status) + 128;
+	    if (WCOREDUMP (status))
+	      fprintf (stderr, _("%s (core dumped)\n"),
+                 strsignal (WTERMSIG (status)));
+	  }
 	else
 	  status = WEXITSTATUS (status);
       else
-- 
1.7.11.4


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux