mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
- 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
This commit is contained in:
parent
8c8345087b
commit
43316b18ff
@ -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 *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: edit.c,v 1.16 2007/09/10 14:29:53 tobias Exp $ */
|
||||
/* $OpenBSD: edit.c,v 1.17 2007/10/17 20:02:33 deraadt Exp $ */
|
||||
/* $NetBSD: edit.c,v 1.5 1996/06/08 19:48:20 christos Exp $ */
|
||||
|
||||
/*
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
static const char rcsid[] = "$OpenBSD: edit.c,v 1.16 2007/09/10 14:29:53 tobias Exp $";
|
||||
static const char rcsid[] = "$OpenBSD: edit.c,v 1.17 2007/10/17 20:02:33 deraadt Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -242,9 +242,9 @@ int
|
||||
editit(const char *ed, const char *pathname)
|
||||
{
|
||||
char *argp[] = {"sh", "-c", NULL, NULL}, *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;
|
||||
|
||||
if (ed == NULL)
|
||||
ed = getenv("VISUAL");
|
||||
@ -259,6 +259,7 @@ editit(const char *ed, 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) {
|
||||
@ -268,22 +269,18 @@ editit(const char *ed, 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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sendbug.c,v 1.51 2007/09/18 00:38:58 ray Exp $ */
|
||||
/* $OpenBSD: sendbug.c,v 1.52 2007/10/17 20:02:33 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Ray Lai <ray@cyth.net>.
|
||||
@ -228,9 +228,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')
|
||||
@ -244,6 +244,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) {
|
||||
@ -253,24 +254,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);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: crontab.c,v 1.53 2007/09/01 02:25:26 ray Exp $ */
|
||||
/* $OpenBSD: crontab.c,v 1.54 2007/10/17 20:02:33 deraadt Exp $ */
|
||||
|
||||
/* Copyright 1988,1990,1993,1994 by Paul Vixie
|
||||
* All rights reserved
|
||||
@ -21,7 +21,7 @@
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
static char const rcsid[] = "$OpenBSD: crontab.c,v 1.53 2007/09/01 02:25:26 ray Exp $";
|
||||
static char const rcsid[] = "$OpenBSD: crontab.c,v 1.54 2007/10/17 20:02:33 deraadt Exp $";
|
||||
|
||||
/* crontab - install and manage per-user crontab files
|
||||
* vix 02may87 [RCS has the rest of the log]
|
||||
@ -598,9 +598,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')
|
||||
@ -614,6 +614,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) {
|
||||
@ -625,24 +626,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);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user