summaryrefslogtreecommitdiffstats
path: root/usr.bin/sendbug/sendbug.c
diff options
context:
space:
mode:
authorray <ray@openbsd.org>2007-05-07 02:11:12 +0000
committerray <ray@openbsd.org>2007-05-07 02:11:12 +0000
commit3cf7ad38e6414665dd7686ce5f2ba5a512caff95 (patch)
treea178533d3db0744e69cfc093c1c9b1099bb52c69 /usr.bin/sendbug/sendbug.c
parentDocument "M active|passive" ui command. (diff)
downloadwireguard-openbsd-3cf7ad38e6414665dd7686ce5f2ba5a512caff95.tar.xz
wireguard-openbsd-3cf7ad38e6414665dd7686ce5f2ba5a512caff95.zip
Simplify some loops.
OK jaredy@ and moritz@.
Diffstat (limited to 'usr.bin/sendbug/sendbug.c')
-rw-r--r--usr.bin/sendbug/sendbug.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/usr.bin/sendbug/sendbug.c b/usr.bin/sendbug/sendbug.c
index f2beedf6f37..3ba65705512 100644
--- a/usr.bin/sendbug/sendbug.c
+++ b/usr.bin/sendbug/sendbug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sendbug.c,v 1.45 2007/05/06 05:01:19 ray Exp $ */
+/* $OpenBSD: sendbug.c,v 1.46 2007/05/07 02:11:12 ray Exp $ */
/*
* Written by Ray Lai <ray@cyth.net>.
@@ -241,39 +241,19 @@ editit(const char *pathname)
sighup = signal(SIGHUP, SIG_IGN);
sigint = signal(SIGINT, SIG_IGN);
sigquit = signal(SIGQUIT, SIG_IGN);
- top:
- if ((pid = fork()) == -1) {
- saved_errno = errno;
-
- if (saved_errno == EAGAIN) {
+ while ((pid = fork()) == -1)
+ if (errno == EAGAIN)
sleep(1);
- goto top;
- }
- (void)signal(SIGHUP, sighup);
- (void)signal(SIGINT, sigint);
- (void)signal(SIGQUIT, sigquit);
- free(p);
- errno = saved_errno;
- return (-1);
- }
+ else
+ goto fail;
if (pid == 0) {
execv(_PATH_BSHELL, argp);
_exit(127);
}
+ while (waitpid(pid, &st, 0) == -1)
+ if (errno != EINTR)
+ goto fail;
free(p);
- for (;;) {
- if (waitpid(pid, &st, 0) == -1) {
- if (errno != EINTR) {
- saved_errno = errno;
- (void)signal(SIGHUP, sighup);
- (void)signal(SIGINT, sigint);
- (void)signal(SIGQUIT, sigquit);
- errno = saved_errno;
- return (-1);
- }
- } else
- break;
- }
(void)signal(SIGHUP, sighup);
(void)signal(SIGINT, sigint);
(void)signal(SIGQUIT, sigquit);
@@ -282,6 +262,15 @@ editit(const char *pathname)
return (-1);
}
return (0);
+
+ fail:
+ saved_errno = errno;
+ (void)signal(SIGHUP, sighup);
+ (void)signal(SIGINT, sigint);
+ (void)signal(SIGQUIT, sigquit);
+ free(p);
+ errno = saved_errno;
+ return (-1);
}
int