Commit | Line | Data |
---|---|---|
60de5df9 | 1 | /* |
46e9ea25 KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
5e8b0e60 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
60de5df9 EW |
16 | */ |
17 | ||
46e9ea25 | 18 | #ifndef lint |
ca67e7b4 | 19 | static char sccsid[] = "@(#)wwchild.c 3.9 (Berkeley) 6/29/88"; |
46e9ea25 KB |
20 | #endif /* not lint */ |
21 | ||
49b6070e | 22 | #include "ww.h" |
51e996e1 | 23 | #include <sys/types.h> |
49b6070e EW |
24 | #include <sys/wait.h> |
25 | ||
26 | wwchild() | |
27 | { | |
eec72f58 EW |
28 | extern errno; |
29 | int olderrno; | |
bb05dfb5 | 30 | register struct ww **wp; |
49b6070e EW |
31 | union wait w; |
32 | int pid; | |
16078900 | 33 | char collected = 0; |
49b6070e | 34 | |
eec72f58 | 35 | olderrno = errno; |
bb05dfb5 EW |
36 | while ((pid = wait3(&w, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) { |
37 | for (wp = wwindex; wp < &wwindex[NWW]; wp++) { | |
38 | if (*wp && (*wp)->ww_state == WWS_HASPROC | |
39 | && (*wp)->ww_pid == pid) { | |
40 | (*wp)->ww_state = WWS_DEAD; | |
16078900 | 41 | collected = 1; |
49b6070e EW |
42 | break; |
43 | } | |
44 | } | |
49b6070e | 45 | } |
eec72f58 | 46 | errno = olderrno; |
16078900 EW |
47 | /* jump out of wwiomux when somebody dies */ |
48 | if (collected) | |
49 | wwsetintr(); | |
49b6070e | 50 | } |