diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2007-03-26 06:40:02 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2007-03-26 06:40:02 +0000 |
commit | 46ddc8936e98a5cc397d23dd462b2b3bc15d7f5e (patch) | |
tree | 7f65dd20cd6ac7be608d8cbefd3f7e35a1ef1524 /usr.bin/sendbug/sendbug.c | |
parent | 1f0e0c9da0e8474c444549a2394b3bcf87306906 (diff) |
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); } |