1 /* 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 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 */ 12 13 #ifndef lint 14 static char sccsid[] = "@(#)wwchild.c 3.8 (Berkeley) 02/21/88"; 15 #endif /* not lint */ 16 17 #include "ww.h" 18 #include <sys/types.h> 19 #include <sys/wait.h> 20 21 wwchild() 22 { 23 extern errno; 24 int olderrno; 25 register struct ww **wp; 26 union wait w; 27 int pid; 28 char collected = 0; 29 30 olderrno = errno; 31 while ((pid = wait3(&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