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.15 (Berkeley) 03/02/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 = 31 wait3((int *)&w, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) { 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; 36 collected = 1; 37 break; 38 } 39 } 40 } 41 errno = olderrno; 42 /* jump out of wwiomux when somebody dies */ 43 if (collected) 44 wwsetintr(); 45 } 46