summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-10-17 20:02:34 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-10-17 20:02:34 +0000
commit4f4368721b2619584d945f74ab23327bad6ac500 (patch)
treeabab3b0ecf47032e485040088bd55f21f3952f39 /sbin
parent1d02ffd46168ad7485a450e43575363fbaa7dca7 (diff)
- 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 'sbin')
-rw-r--r--sbin/disklabel/disklabel.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 31a9a30e6b8..9ac8c5e4cd8 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.119 2007/10/15 02:16:35 deraadt Exp $ */
+/* $OpenBSD: disklabel.c,v 1.120 2007/10/17 20:02:30 deraadt Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -39,7 +39,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.119 2007/10/15 02:16:35 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.120 2007/10/17 20:02:30 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -1192,9 +1192,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')
@@ -1208,6 +1208,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) {
@@ -1217,24 +1218,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);
}
char *