From 717eb3fdf2374c28e853468dccffd214b59e75c7 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 2 Nov 2001 17:52:12 +0000 Subject: [PATCH] Change 2 Exit() -> exit() 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 | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/visudo.c b/visudo.c index adbf3c86f..6f3e7035a 100644 --- 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); } -- 2.50.1