version 1.14, 1997/11/14 00:23:54 |
version 1.15, 1998/02/15 21:20:02 |
|
|
int status; |
int status; |
struct child *link; |
struct child *link; |
}; |
}; |
static struct child *child; |
static struct child *child, *child_freelist = NULL; |
static struct child *findchild __P((int)); |
static struct child *findchild __P((int, int)); |
static void delchild __P((struct child *)); |
static void delchild __P((struct child *)); |
static int file_pid __P((FILE *)); |
static int file_pid __P((FILE *)); |
static int handle_spool_locks __P((int)); |
static int handle_spool_locks __P((int)); |
|
|
} |
} |
|
|
static struct child * |
static struct child * |
findchild(pid) |
findchild(pid, dont_alloc) |
int pid; |
int pid; |
|
int dont_alloc; |
{ |
{ |
struct child **cpp; |
struct child **cpp; |
|
|
|
|
cpp = &(*cpp)->link) |
cpp = &(*cpp)->link) |
; |
; |
if (*cpp == NULL) { |
if (*cpp == NULL) { |
*cpp = (struct child *)malloc(sizeof(struct child)); |
if (dont_alloc) |
|
return(NULL); |
|
if (child_freelist) { |
|
*cpp = child_freelist; |
|
child_freelist = (*cpp)->link; |
|
} else |
|
*cpp = (struct child *)malloc(sizeof(struct child)); |
(*cpp)->pid = pid; |
(*cpp)->pid = pid; |
(*cpp)->done = (*cpp)->free = 0; |
(*cpp)->done = (*cpp)->free = 0; |
(*cpp)->link = NULL; |
(*cpp)->link = NULL; |
|
|
for (cpp = &child; *cpp != cp; cpp = &(*cpp)->link) |
for (cpp = &child; *cpp != cp; cpp = &(*cpp)->link) |
; |
; |
*cpp = cp->link; |
*cpp = cp->link; |
(void)free(cp); |
cp->link = child_freelist; |
|
child_freelist = cp; |
} |
} |
|
|
void |
void |
|
|
|
|
while ((pid = |
while ((pid = |
waitpid((pid_t)-1, &status, WNOHANG)) > 0) { |
waitpid((pid_t)-1, &status, WNOHANG)) > 0) { |
cp = findchild(pid); |
cp = findchild(pid, 1); |
|
if (!cp) |
|
continue; |
if (cp->free) |
if (cp->free) |
delchild(cp); |
delchild(cp); |
else { |
else { |
|
|
wait_child(pid) |
wait_child(pid) |
int pid; |
int pid; |
{ |
{ |
struct child *cp = findchild(pid); |
struct child *cp = findchild(pid, 0); |
sigset_t nset, oset; |
sigset_t nset, oset; |
|
|
sigemptyset(&nset); |
sigemptyset(&nset); |
|
|
free_child(pid) |
free_child(pid) |
int pid; |
int pid; |
{ |
{ |
struct child *cp = findchild(pid); |
struct child *cp = findchild(pid, 0); |
sigset_t nset, oset; |
sigset_t nset, oset; |
|
|
sigemptyset(&nset); |
sigemptyset(&nset); |