version 1.19, 1998/08/15 23:17:24 |
version 1.20, 1998/09/08 15:24:38 |
|
|
* Run a command without a shell, with optional arguments and splicing |
* Run a command without a shell, with optional arguments and splicing |
* of stdin and stdout. The command name can be a sequence of words. |
* of stdin and stdout. The command name can be a sequence of words. |
* Signals must be handled by the caller. |
* Signals must be handled by the caller. |
* "Mask" contains the signals to ignore in the new process. |
* "nset" contains the signals to ignore in the new process. |
* SIGINT is enabled unless it's in the mask. |
* SIGINT is enabled unless it's in "nset". |
*/ |
*/ |
/*VARARGS4*/ |
/*VARARGS4*/ |
int |
int |
|
|
wait_child(pid) |
wait_child(pid) |
int pid; |
int pid; |
{ |
{ |
struct child *cp = findchild(pid, 0); |
struct child *cp; |
sigset_t nset, oset; |
sigset_t nset, oset; |
|
|
if (cp == NULL) |
|
return(-1); |
|
|
|
sigemptyset(&nset); |
sigemptyset(&nset); |
sigaddset(&nset, SIGCHLD); |
sigaddset(&nset, SIGCHLD); |
sigprocmask(SIG_BLOCK, &nset, &oset); |
sigprocmask(SIG_BLOCK, &nset, &oset); |
|
|
|
if ((cp = findchild(pid, 0)) == NULL) |
|
return(-1); |
|
|
while (!cp->done) |
while (!cp->done) |
sigsuspend(&oset); |
sigsuspend(&oset); |
wait_status = cp->status; |
wait_status = cp->status; |
|
|
free_child(pid) |
free_child(pid) |
int pid; |
int pid; |
{ |
{ |
struct child *cp = findchild(pid, 0); |
struct child *cp; |
sigset_t nset, oset; |
sigset_t nset, oset; |
|
|
if (cp == NULL) |
|
return; |
|
|
|
sigemptyset(&nset); |
sigemptyset(&nset); |
sigaddset(&nset, SIGCHLD); |
sigaddset(&nset, SIGCHLD); |
sigprocmask(SIG_BLOCK, &nset, &oset); |
sigprocmask(SIG_BLOCK, &nset, &oset); |
|
|
|
if ((cp = findchild(pid, 0)) == NULL) |
|
return; |
|
|
if (cp->done) |
if (cp->done) |
delchild(cp); |
delchild(cp); |