summaryrefslogtreecommitdiff
path: root/usr.bin/sendbug/sendbug.c
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2007-05-06 05:01:20 +0000
committerRay Lai <ray@cvs.openbsd.org>2007-05-06 05:01:20 +0000
commit5639f1d79926244fa97afdf6129d7e73927fa389 (patch)
tree6f86078b06244acf97a133521ee6097b173e385b /usr.bin/sendbug/sendbug.c
parent3f21977d59831078de222df18ae9a52da3234d23 (diff)
Restore signals before returning.
Diffstat (limited to 'usr.bin/sendbug/sendbug.c')
-rw-r--r--usr.bin/sendbug/sendbug.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/sendbug/sendbug.c b/usr.bin/sendbug/sendbug.c
index 1431f7fe2a2..f2beedf6f37 100644
--- a/usr.bin/sendbug/sendbug.c
+++ b/usr.bin/sendbug/sendbug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sendbug.c,v 1.44 2007/05/06 04:50:26 ray Exp $ */
+/* $OpenBSD: sendbug.c,v 1.45 2007/05/06 05:01:19 ray Exp $ */
/*
* Written by Ray Lai <ray@cyth.net>.
@@ -227,7 +227,7 @@ editit(const char *pathname)
char *argp[] = {"sh", "-c", NULL, NULL}, *ed, *p;
sig_t sighup, sigint, sigquit;
pid_t pid;
- int st;
+ int saved_errno, st;
ed = getenv("VISUAL");
if (ed == NULL || ed[0] == '\0')
@@ -243,7 +243,7 @@ editit(const char *pathname)
sigquit = signal(SIGQUIT, SIG_IGN);
top:
if ((pid = fork()) == -1) {
- int saved_errno = errno;
+ saved_errno = errno;
if (saved_errno == EAGAIN) {
sleep(1);
@@ -263,8 +263,14 @@ editit(const char *pathname)
free(p);
for (;;) {
if (waitpid(pid, &st, 0) == -1) {
- if (errno != EINTR)
+ 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;
}