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