113921Sedward #ifndef lint 2*31443Sedward static char sccsid[] = "@(#)wwchild.c 3.7 06/08/87"; 313921Sedward #endif 413921Sedward 518727Sedward /* 618727Sedward * Copyright (c) 1983 Regents of the University of California, 718727Sedward * All rights reserved. Redistribution permitted subject to 818727Sedward * the terms of the Berkeley Software License Agreement. 918727Sedward */ 1018727Sedward 1113921Sedward #include "ww.h" 1231046Ssam #include <sys/types.h> 1313921Sedward #include <sys/wait.h> 1413921Sedward 1513921Sedward wwchild() 1613921Sedward { 1715630Sedward extern errno; 1815630Sedward int olderrno; 1914407Sedward register struct ww **wp; 2013921Sedward union wait w; 2113921Sedward int pid; 22*31443Sedward char collected = 0; 2313921Sedward 2415630Sedward olderrno = errno; 2514407Sedward while ((pid = wait3(&w, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) { 2614407Sedward for (wp = wwindex; wp < &wwindex[NWW]; wp++) { 2714407Sedward if (*wp && (*wp)->ww_state == WWS_HASPROC 2814407Sedward && (*wp)->ww_pid == pid) { 2914407Sedward (*wp)->ww_state = WWS_DEAD; 30*31443Sedward collected = 1; 3113921Sedward break; 3213921Sedward } 3313921Sedward } 3413921Sedward } 3515630Sedward errno = olderrno; 36*31443Sedward /* jump out of wwiomux when somebody dies */ 37*31443Sedward if (collected) 38*31443Sedward wwsetintr(); 3913921Sedward } 40