]> granicus.if.org Git - sudo/commitdiff
Change 2 Exit() -> exit()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 2 Nov 2001 17:52:12 +0000 (17:52 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 2 Nov 2001 17:52:12 +0000 (17:52 +0000)
Avoid stdio in Exit() and call _exit() if we are a signal handler.
We no longer print the signal number but the user can just check the
exit value for that.

visudo.c

index adbf3c86fa2fe3dc68bf51b9266d9f4028b9379b..6f3e7035a406b3556f236fee3042f004ca9d8c07 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -171,7 +171,7 @@ main(argc, argv)
     if (sudoers_fd == -1) {
        (void) fprintf(stderr, "%s: %s: %s\n", Argv[0], sudoers,
            strerror(errno));
-       Exit(-1);
+       exit(1);
     }
     if (!lock_file(sudoers_fd, SUDO_TLOCK)) {
        (void) fprintf(stderr, "%s: sudoers file busy, try again later.\n",
@@ -185,7 +185,7 @@ main(argc, argv)
 #endif
        (void) fprintf(stderr, "%s: can't stat %s: %s\n",
            Argv[0], sudoers, strerror(errno));
-       Exit(-1);
+       exit(1);
     }
 
     /*
@@ -647,26 +647,21 @@ run_command(path, argv)
 /*
  * Unlink the sudoers temp file (if it exists) and exit.
  * Used in place of a normal exit() and as a signal handler.
- * A positive parameter is considered to be a signal and is reported.
+ * A positive parameter indicates we were called as a signal handler.
  */
 static RETSIGTYPE
 Exit(sig)
     int sig;
 {
-#ifdef POSIX_SIGNALS
-    sigset_t mask;
-
-    sigfillset(&mask);
-    (void) sigprocmask(SIG_BLOCK, &mask, NULL);
-#else
-    (void) sigblock(~0);
-#endif /* POSIX_SIGNALS */
+    char *emsg = " exiting due to signal.\n";
 
     (void) unlink(stmp);
 
-    if (sig > 0)
-       (void) fprintf(stderr, "%s exiting, caught signal %d.\n", Argv[0], sig);
-
+    if (sig > 0) {
+       write(STDERR_FILENO, Argv[0], strlen(Argv[0]));
+       write(STDERR_FILENO, emsg, sizeof(emsg) - 1);
+       _exit(-sig);
+    }
     exit(-sig);
 }