diff options
Diffstat (limited to 'usr.bin/sdiff')
-rw-r--r-- | usr.bin/sdiff/edit.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/usr.bin/sdiff/edit.c b/usr.bin/sdiff/edit.c index ba94a3f84d4..47a222f5a42 100644 --- a/usr.bin/sdiff/edit.c +++ b/usr.bin/sdiff/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.17 2007/05/11 02:47:52 ray Exp $ */ +/* $OpenBSD: edit.c,v 1.18 2007/10/17 20:02:33 deraadt Exp $ */ /* * Written by Raymond Lai <ray@cyth.net>. @@ -33,9 +33,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') @@ -49,6 +49,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) { @@ -58,24 +59,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); } /* |