diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-02-16 07:42:53 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-02-16 07:42:53 +0000 |
commit | 819a4dd2e221dc1ff4eb32d0dadb01374605e32e (patch) | |
tree | 26ea028eb32b52783482b899980b5b4dc235322a /sbin | |
parent | 9db0fce6a101b8d20b69fe896eca357e1920e7aa (diff) |
when spawning editor child, use signal() instead of sigprocmask(SIG_BLOCK...
this appears to prevent the intermediate shell from playing with the signals
such that it gets a tty signal inside an editor such as emacs.
this was very annoying
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/disklabel.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 62035780ff2..4ad2de9a76d 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.26 1996/12/13 16:58:25 millert Exp $ */ +/* $OpenBSD: disklabel.c,v 1.27 1997/02/16 07:42:52 deraadt Exp $ */ /* $NetBSD: disklabel.c,v 1.30 1996/03/14 19:49:24 ghudson Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char rcsid[] = "$OpenBSD: disklabel.c,v 1.26 1996/12/13 16:58:25 millert Exp $"; +static char rcsid[] = "$OpenBSD: disklabel.c,v 1.27 1997/02/16 07:42:52 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -960,7 +960,6 @@ editit() int pid, xpid; int stat; extern char *getenv(); - sigset_t sigset, osigset; char *argp[] = {"sh", "-c", NULL, NULL}; char *ed, *p; @@ -974,24 +973,20 @@ editit() sprintf(p, "%s %s", ed, tmpfil); argp[2] = p; - sigemptyset(&sigset); - sigaddset(&sigset, SIGINT); - sigaddset(&sigset, SIGQUIT); - sigaddset(&sigset, SIGHUP); - sigprocmask(SIG_BLOCK, &sigset, &osigset); + /* Turn off signals. */ + (void)signal(SIGHUP, SIG_IGN); + (void)signal(SIGINT, SIG_IGN); + (void)signal(SIGQUIT, SIG_IGN); while ((pid = fork()) < 0) { if (errno != EAGAIN) { - sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); warn("fork"); free(p); - return (0); + stat = 1; + goto bail; } sleep(1); } if (pid == 0) { - sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); - setgid(getgid()); - setuid(getuid()); execv(_PATH_BSHELL, argp); _exit(127); } @@ -1003,7 +998,10 @@ editit() else if (WIFEXITED(stat)) break; } - sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); +bail: + (void)signal(SIGHUP, SIG_DFL); + (void)signal(SIGINT, SIG_DFL); + (void)signal(SIGQUIT, SIG_DFL); return (!stat); } |