[git commit] logread: intercept all fatal signals, not just SIGINT

Denys Vlasenko vda.linux at googlemail.com
Sun Jul 28 21:17:00 UTC 2013


commit: http://git.busybox.net/busybox/commit/?id=2641426187550fb2ba10f249a97e994fec26848a
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
interrupted                                           27      20      -7

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 sysklogd/logread.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/sysklogd/logread.c b/sysklogd/logread.c
index 9939569..2b6415f 100644
--- a/sysklogd/logread.c
+++ b/sysklogd/logread.c
@@ -52,7 +52,7 @@ struct globals {
 static void error_exit(const char *str) NORETURN;
 static void error_exit(const char *str)
 {
-	//release all acquired resources
+	/* Release all acquired resources */
 	shmdt(shbuf);
 	bb_perror_msg_and_die(str);
 }
@@ -66,11 +66,10 @@ static void sem_up(int semid)
 		error_exit("semop[SMrup]");
 }
 
-static void interrupted(int sig UNUSED_PARAM)
+static void interrupted(int sig)
 {
-	signal(SIGINT, SIG_IGN);
 	shmdt(shbuf);
-	exit(EXIT_SUCCESS);
+	kill_myself_with_sig(sig);
 }
 
 int logread_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -96,7 +95,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
 	if (log_semid == -1)
 		error_exit("can't get access to semaphores for syslogd buffer");
 
-	signal(SIGINT, interrupted);
+	bb_signals(BB_FATAL_SIGS, interrupted);
 
 	/* Suppose atomic memory read */
 	/* Max possible value for tail is shbuf->size - 1 */


More information about the busybox-cvs mailing list