summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-11-02 17:59:07 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-11-02 17:59:07 +0000
commitaccd3981b0d7c6ee216e140a3d3fe01e83247315 (patch)
tree7c35e9300158962c2bc3e92da6b7cb8d814a8c1c
parentd6f0bc5604264a930e3e520cf142dad1bb7818a3 (diff)
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.
-rw-r--r--usr.bin/sudo/visudo.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/sudo/visudo.c b/usr.bin/sudo/visudo.c
index 293bcf8dd32..559c1919f97 100644
--- a/usr.bin/sudo/visudo.c
+++ b/usr.bin/sudo/visudo.c
@@ -170,7 +170,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",
@@ -184,7 +184,7 @@ main(argc, argv)
#endif
(void) fprintf(stderr, "%s: can't stat %s: %s\n",
Argv[0], sudoers, strerror(errno));
- Exit(-1);
+ exit(1);
}
/*
@@ -499,18 +499,22 @@ setup_signals()
/*
* 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;
{
- (void) unlink(stmp);
+ char *emsg = " exiting due to signal.\n";
- if (sig > 0) /* XXX signal race */
- (void) fprintf(stderr, "%s exiting, caught signal %d.\n", Argv[0], sig);
+ (void) unlink(stmp);
- exit(-sig); /* XXX for signal case, should be _exit() */
+ if (sig > 0) {
+ write(STDERR_FILENO, Argv[0], strlen(Argv[0]));
+ write(STDERR_FILENO, emsg, sizeof(emsg) - 1);
+ _exit(-sig);
+ }
+ exit(-sig);
}
static void