diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2007-03-26 05:50:19 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2007-03-26 05:50:19 +0000 |
commit | bb54122a84470fcdf543564b5e481db65c66bec4 (patch) | |
tree | 308ffdf791039e17bf6eeee63e1aedd3e3cad3d9 /usr.bin/sendbug/sendbug.c | |
parent | d8be412b301ec4090b9988e522fa32a9d53528e6 (diff) |
Save and restore signal handlers. Although we do not install our
own signal handlers, this allows this code to be more easily reused
in other programs.
OK deraadt@
Diffstat (limited to 'usr.bin/sendbug/sendbug.c')
-rw-r--r-- | usr.bin/sendbug/sendbug.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/sendbug/sendbug.c b/usr.bin/sendbug/sendbug.c index 6269c00113e..2227cb83150 100644 --- a/usr.bin/sendbug/sendbug.c +++ b/usr.bin/sendbug/sendbug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sendbug.c,v 1.24 2007/03/26 05:39:51 ray Exp $ */ +/* $OpenBSD: sendbug.c,v 1.25 2007/03/26 05:50:18 ray Exp $ */ /* * Written by Ray Lai <ray@cyth.net>. @@ -166,6 +166,7 @@ int editit(char *tmpfile) { char *argp[] = {"sh", "-c", NULL, NULL}, *ed, *p; + sig_t sighup, sigint, sigquit; pid_t pid, xpid; int st; @@ -176,15 +177,15 @@ editit(char *tmpfile) argp[2] = p; top: - (void)signal(SIGHUP, SIG_IGN); - (void)signal(SIGINT, SIG_IGN); - (void)signal(SIGQUIT, SIG_IGN); + sighup = signal(SIGHUP, SIG_IGN); + sigint = signal(SIGINT, SIG_IGN); + sigquit = signal(SIGQUIT, SIG_IGN); if ((pid = fork()) == -1) { int saved_errno = errno; - (void)signal(SIGHUP, SIG_DFL); - (void)signal(SIGINT, SIG_DFL); - (void)signal(SIGQUIT, SIG_DFL); + (void)signal(SIGHUP, sighup); + (void)signal(SIGINT, sigint); + (void)signal(SIGQUIT, sigquit); if (saved_errno == EAGAIN) { sleep(1); goto top; @@ -211,9 +212,9 @@ editit(char *tmpfile) else if (WIFEXITED(st)) break; } - (void)signal(SIGHUP, SIG_DFL); - (void)signal(SIGINT, SIG_DFL); - (void)signal(SIGQUIT, SIG_DFL); + (void)signal(SIGHUP, sighup); + (void)signal(SIGINT, sigint); + (void)signal(SIGQUIT, sigquit); if (!WIFEXITED(st) || WEXITSTATUS(st) != 0) return (-1); return (0); |