changeset 1727:c0ef9b7976f0 draft

Use xsignal() instead of signal().
author Rob Landley <rob@landley.net>
date Tue, 10 Mar 2015 11:07:28 -0500
parents 26170eb7685d
children d7e43cc0f525
files toys/other/login.c toys/other/netcat.c toys/other/timeout.c toys/posix/nohup.c toys/posix/tee.c
diffstat 5 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/toys/other/login.c	Mon Mar 09 15:06:10 2015 -0500
+++ b/toys/other/login.c	Tue Mar 10 11:07:28 2015 -0500
@@ -156,7 +156,7 @@
   if (!isatty(0) || !isatty(1) || !isatty(2)) error_exit("no tty");
 
   openlog("login", LOG_PID | LOG_CONS, LOG_AUTH);
-  signal(SIGALRM, login_timeout_handler);
+  xsignal(SIGALRM, login_timeout_handler);
   alarm(TT.login_timeout = 60);
 
   for (ss = forbid; *ss; ss++) unsetenv(*ss);
--- a/toys/other/netcat.c	Mon Mar 09 15:06:10 2015 -0500
+++ b/toys/other/netcat.c	Tue Mar 10 11:07:28 2015 -0500
@@ -54,12 +54,13 @@
 static void timeout(int signum)
 {
   if (TT.wait) error_exit("Timeout");
+  // This should be xexit() but would need siglongjmp()...
   exit(0);
 }
 
 static void set_alarm(int seconds)
 {
-  signal(SIGALRM, seconds ? timeout : SIG_DFL);
+  xsignal(SIGALRM, seconds ? timeout : SIG_DFL);
   alarm(seconds);
 }
 
--- a/toys/other/timeout.c	Mon Mar 09 15:06:10 2015 -0500
+++ b/toys/other/timeout.c	Tue Mar 10 11:07:28 2015 -0500
@@ -45,7 +45,7 @@
   if (TT.k_timeout) {
     TT.k_timeout = 0;
     TT.nextsig = SIGKILL;
-    signal(SIGALRM, handler);
+    xsignal(SIGALRM, handler);
     TT.itv.it_value = TT.ktv;
     setitimer(ITIMER_REAL, &TT.itv, (void *)toybuf);
   }
@@ -66,7 +66,7 @@
   else {
     int status;
 
-    signal(SIGALRM, handler);
+    xsignal(SIGALRM, handler);
     setitimer(ITIMER_REAL, &TT.itv, (void *)toybuf);
     while (-1 == waitpid(TT.pid, &status, 0) && errno == EINTR);
     toys.exitval = WIFEXITED(status)
--- a/toys/posix/nohup.c	Mon Mar 09 15:06:10 2015 -0500
+++ b/toys/posix/nohup.c	Tue Mar 10 11:07:28 2015 -0500
@@ -21,7 +21,7 @@
 
 void nohup_main(void)
 {
-  signal(SIGHUP, SIG_IGN);
+  xsignal(SIGHUP, SIG_IGN);
   if (isatty(1)) {
     close(1);
     if (-1 == open("nohup.out", O_CREAT|O_APPEND|O_WRONLY,
--- a/toys/posix/tee.c	Mon Mar 09 15:06:10 2015 -0500
+++ b/toys/posix/tee.c	Tue Mar 10 11:07:28 2015 -0500
@@ -45,7 +45,7 @@
 
 void tee_main(void)
 {
-  if (toys.optflags & FLAG_i) signal(SIGINT, SIG_IGN);
+  if (toys.optflags & FLAG_i) xsignal(SIGINT, SIG_IGN);
 
   // Open output files
   loopfiles_rw(toys.optargs,