diff options
author | deraadt <deraadt@openbsd.org> | 2007-10-17 20:02:30 +0000 |
---|---|---|
committer | deraadt <deraadt@openbsd.org> | 2007-10-17 20:02:30 +0000 |
commit | 43316b18ff37b0feff819091438b5aac1a5cb031 (patch) | |
tree | a15045cfac31930f72ed094e2328423378c04f67 /usr.sbin/edquota | |
parent | Convert MALLOC/FREE to malloc/free. (diff) | |
download | wireguard-openbsd-43316b18ff37b0feff819091438b5aac1a5cb031.tar.xz wireguard-openbsd-43316b18ff37b0feff819091438b5aac1a5cb031.zip |
- Be more careful about pre-existing SIGCHLD handlers (or SIG_IGN) by
temporarily restoring default behaviour. This is not 100% ideal.
But this fixes editor handling in mail... bah, it is really unfortunate
that got broken
- refactor the restoration code as well, to make it simpler
ok ray
Diffstat (limited to 'usr.sbin/edquota')
-rw-r--r-- | usr.sbin/edquota/edquota.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index cb04b0c067a..4b41f31890a 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -38,7 +38,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)edquota.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$Id: edquota.c,v 1.47 2007/08/31 23:14:21 ray Exp $"; +static char *rcsid = "$Id: edquota.c,v 1.48 2007/10/17 20:02:33 deraadt Exp $"; #endif /* not lint */ /* @@ -361,9 +361,9 @@ int editit(const char *pathname) { char *argp[] = {"sh", "-c", NULL, NULL}, *ed, *p; - sig_t sighup, sigint, sigquit; + sig_t sighup, sigint, sigquit, sigchld; pid_t pid; - int saved_errno, st; + int saved_errno, st, ret = -1; ed = getenv("VISUAL"); if (ed == NULL || ed[0] == '\0') @@ -377,6 +377,7 @@ editit(const char *pathname) sighup = signal(SIGHUP, SIG_IGN); sigint = signal(SIGINT, SIG_IGN); sigquit = signal(SIGQUIT, SIG_IGN); + sigchld = signal(SIGCHLD, SIG_DFL); if ((pid = fork()) == -1) goto fail; if (pid == 0) { @@ -386,24 +387,20 @@ editit(const char *pathname) while (waitpid(pid, &st, 0) == -1) if (errno != EINTR) goto fail; - free(p); - (void)signal(SIGHUP, sighup); - (void)signal(SIGINT, sigint); - (void)signal(SIGQUIT, sigquit); - if (!WIFEXITED(st)) { + if (!WIFEXITED(st)) errno = EINTR; - return (-1); - } - return (WEXITSTATUS(st)); + else + ret = WEXITSTATUS(st); fail: saved_errno = errno; (void)signal(SIGHUP, sighup); (void)signal(SIGINT, sigint); (void)signal(SIGQUIT, sigquit); + (void)signal(SIGCHLD, sigchld); free(p); errno = saved_errno; - return (-1); + return (ret); } /* |