Hello there,

attached is an effort to implement the new
signal handling using 'sigaction' for the
applet 'tee'. My testing does produce the
expacted behaviour to ignore SIGINT. The 
downside is a growth of the code:

   text    data     bss     dec     hex filename
    425       0       0     425     1a9 tee.o
    364       0       0     364     16c tee.o.orig

Regards,   Mats E A
diff -Na -u1 Config.in.orig Config.in
--- Config.in.orig	2007-04-11 13:17:54.821020632 +0200
+++ Config.in	2007-04-11 15:06:54.012912360 +0200
@@ -600,2 +600,10 @@
 
+config FEATURE_TEE_POSIX_SIGACTION
+	bool "Enable use of POSIX sigaction instead of old signal."
+	default n
+	depends on TEE
+	help
+	  This invokes the safer sigaction infrastructure for signal
+	  handling. The code grows somewhat.
+
 config TEST
#
#
#
diff -Na -u1 tee.c.orig tee.c
--- tee.c.orig	2007-04-11 12:01:12.968608536 +0200
+++ tee.c	2007-04-11 14:09:01.281847728 +0200
@@ -30,2 +30,6 @@
 #endif
+#if ENABLE_FEATURE_TEE_POSIX_SIGACTION
+	struct sigaction sa;
+#endif
+
 	retval = getopt32(argc, argv, "ia");	/* 'a' must be 2nd */
@@ -36,2 +40,15 @@
 
+#if ENABLE_FEATURE_TEE_POSIX_SIGACTION
+	memset(&sa, 0, sizeof(sa));
+	sigemptyset(&sa.sa_mask);
+	sa.sa_handler = SIG_IGN;
+	sa.sa_flags = SA_RESTART;
+	sigaction(SIGPIPE, &sa, NULL);
+
+	if (retval & 1) {
+		/* sa.sa_mask and sa.sa_flags initiated already above. */
+		/* sa.sa_handler = SIG_IGN; // Also active from before. */
+		sigaction(SIGINT, &sa, NULL);
+	}
+#else
 	if (retval & 1) {
@@ -39,3 +56,2 @@
 	}
-	retval = EXIT_SUCCESS;
 	/* gnu tee ignores SIGPIPE in case one of the output files is a pipe
@@ -43,2 +59,5 @@
 	signal(SIGPIPE, SIG_IGN);	/* TODO - switch to sigaction. */
+#endif
+
+	retval = EXIT_SUCCESS;
 
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to