version 1.9, 2001/07/09 07:04:47 |
version 1.10, 2001/09/04 23:35:58 |
|
|
{ |
{ |
static char *name, *shell; |
static char *name, *shell; |
pid_t pid; |
pid_t pid; |
int omask, pstat; |
int pstat; |
|
sigset_t mask, omask; |
sig_t intsave, quitsave; |
sig_t intsave, quitsave; |
|
|
if (shell == NULL) { |
if (shell == NULL) { |
|
|
if (!command) /* just checking... */ |
if (!command) /* just checking... */ |
return(1); |
return(1); |
|
|
omask = sigblock(sigmask(SIGCHLD)); |
sigemptyset(&mask); |
|
sigaddset(&mask, SIGCHLD); |
|
sigprocmask(SIG_BLOCK, &mask, &omask); |
switch(pid = fork()) { |
switch(pid = fork()) { |
case -1: /* error */ |
case -1: /* error */ |
err(1, "fork"); |
err(1, "fork"); |
case 0: /* child */ |
case 0: /* child */ |
(void)sigsetmask(omask); |
sigprocmask(SIG_SETMASK, &omask, NULL); |
execl(shell, name, "-c", command, (char *)NULL); |
execl(shell, name, "-c", command, (char *)NULL); |
err(1, "%s", shell); |
err(1, "%s", shell); |
} |
} |
intsave = signal(SIGINT, SIG_IGN); |
intsave = signal(SIGINT, SIG_IGN); |
quitsave = signal(SIGQUIT, SIG_IGN); |
quitsave = signal(SIGQUIT, SIG_IGN); |
pid = waitpid(pid, &pstat, 0); |
pid = waitpid(pid, &pstat, 0); |
(void)sigsetmask(omask); |
sigprocmask(SIG_SETMASK, &omask, NULL); |
(void)signal(SIGINT, intsave); |
(void)signal(SIGINT, intsave); |
(void)signal(SIGQUIT, quitsave); |
(void)signal(SIGQUIT, quitsave); |
return(pid == -1 ? -1 : pstat); |
return(pid == -1 ? -1 : pstat); |