Use xsignal() instead of signal().
authorRob Landley <rob@landley.net>
Tue, 10 Mar 2015 16:07:28 +0000 (11:07 -0500)
committerRob Landley <rob@landley.net>
Tue, 10 Mar 2015 16:07:28 +0000 (11:07 -0500)
toys/other/login.c
toys/other/netcat.c
toys/other/timeout.c
toys/posix/nohup.c
toys/posix/tee.c

index 0d6d364..837dd97 100644 (file)
@@ -156,7 +156,7 @@ void login_main(void)
   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);
index d27aa88..453a7ca 100644 (file)
@@ -54,12 +54,13 @@ GLOBALS(
 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);
 }
 
index 6da2d2e..06b1e89 100644 (file)
@@ -45,7 +45,7 @@ static void handler(int i)
   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 @@ void timeout_main(void)
   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)
index 658ab93..4d6d59f 100644 (file)
@@ -21,7 +21,7 @@ config NOHUP
 
 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,
index 0388510..909ea58 100644 (file)
@@ -45,7 +45,7 @@ static void do_tee_open(int fd, char *name)
 
 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,