diff options
author | 2007-03-26 06:40:01 +0000 | |
---|---|---|
committer | 2007-03-26 06:40:01 +0000 | |
commit | 2bba59c0e4335247a295ff13b8d826cf78d50043 (patch) | |
tree | 50d1a8b48be9c4e574447e119cabfb746a59a32a /usr.bin/sendbug/sendbug.c | |
parent | Accept $VISUAL in addition to $EDITOR. (diff) | |
download | wireguard-openbsd-2bba59c0e4335247a295ff13b8d826cf78d50043.tar.xz wireguard-openbsd-2bba59c0e4335247a295ff13b8d826cf78d50043.zip |
Don't print warnings in editit(), instead make errno reliable on
failure. If the editor exits non-zero, errno is set to ECHILD.
OK deraadt@.
Diffstat (limited to 'usr.bin/sendbug/sendbug.c')
-rw-r--r-- | usr.bin/sendbug/sendbug.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/usr.bin/sendbug/sendbug.c b/usr.bin/sendbug/sendbug.c index b83e66c6db6..424f12b3fff 100644 --- a/usr.bin/sendbug/sendbug.c +++ b/usr.bin/sendbug/sendbug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sendbug.c,v 1.26 2007/03/26 06:22:12 ray Exp $ */ +/* $OpenBSD: sendbug.c,v 1.27 2007/03/26 06:40:01 ray Exp $ */ /* * Written by Ray Lai <ray@cyth.net>. @@ -193,9 +193,8 @@ editit(char *tmpfile) sleep(1); goto top; } - errno = saved_errno; - perror("fork"); free(p); + errno = saved_errno; return (-1); } if (pid == 0) { @@ -206,10 +205,8 @@ editit(char *tmpfile) for (;;) { xpid = waitpid(pid, (int *)&st, WUNTRACED); if (xpid == -1) { - if (errno != EINTR) { - warn("waidpid"); + if (errno != EINTR) return (-1); - } } else if (WIFSTOPPED(st)) raise(WSTOPSIG(st)); else if (WIFEXITED(st)) @@ -218,8 +215,10 @@ editit(char *tmpfile) (void)signal(SIGHUP, sighup); (void)signal(SIGINT, sigint); (void)signal(SIGQUIT, sigquit); - if (!WIFEXITED(st) || WEXITSTATUS(st) != 0) + if (!WIFEXITED(st) || WEXITSTATUS(st) != 0) { + errno = ECHILD; return (-1); + } return (0); } |