Commit | Line | Data |
---|---|---|
60de5df9 | 1 | /* |
46e9ea25 KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
3dd3a9e5 KB |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Edward Wang at The University of California, Berkeley. | |
7 | * | |
87f529ec | 8 | * %sccs.include.redist.c% |
60de5df9 EW |
9 | */ |
10 | ||
46e9ea25 | 11 | #ifndef lint |
419d8eab | 12 | static char sccsid[] = "@(#)wwchild.c 3.15 (Berkeley) %G%"; |
46e9ea25 KB |
13 | #endif /* not lint */ |
14 | ||
49b6070e | 15 | #include "ww.h" |
17918234 | 16 | #include <sys/types.h> |
49b6070e EW |
17 | #include <sys/wait.h> |
18 | ||
a50b4763 | 19 | void |
49b6070e EW |
20 | wwchild() |
21 | { | |
eec72f58 EW |
22 | extern errno; |
23 | int olderrno; | |
bb05dfb5 | 24 | register struct ww **wp; |
49b6070e EW |
25 | union wait w; |
26 | int pid; | |
16078900 | 27 | char collected = 0; |
49b6070e | 28 | |
eec72f58 | 29 | olderrno = errno; |
419d8eab KB |
30 | while ((pid = |
31 | wait3((int *)&w, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) { | |
bb05dfb5 EW |
32 | for (wp = wwindex; wp < &wwindex[NWW]; wp++) { |
33 | if (*wp && (*wp)->ww_state == WWS_HASPROC | |
34 | && (*wp)->ww_pid == pid) { | |
35 | (*wp)->ww_state = WWS_DEAD; | |
16078900 | 36 | collected = 1; |
49b6070e EW |
37 | break; |
38 | } | |
39 | } | |
49b6070e | 40 | } |
eec72f58 | 41 | errno = olderrno; |
16078900 EW |
42 | /* jump out of wwiomux when somebody dies */ |
43 | if (collected) | |
44 | wwsetintr(); | |
49b6070e | 45 | } |