new io scheme
[unix-history] / usr / src / usr.bin / window / wwchild.c
index 8695eda..c62cb18 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwchild.c   1.3 83/07/18";
+static char *sccsid = "@(#)wwchild.c   3.3 83/12/01";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -7,24 +7,21 @@ static        char *sccsid = "@(#)wwchild.c   1.3 83/07/18";
 
 wwchild()
 {
 
 wwchild()
 {
-       register struct ww *wp;
+       extern errno;
+       int olderrno;
+       register struct ww **wp;
        union wait w;
        int pid;
 
        union wait w;
        int pid;
 
-       while ((pid = wait3(&w, WNOHANG|WUNTRACED, 0)) > 0) {
-               for (wp = wwhead; wp; wp = wp->ww_next) {
-                       if (wp->ww_pid == pid) {
-                               wp->ww_state = WW_DEAD;
-                               /*
-                               wwprintf(curwin,
-                                       "\r\n%d: Died\r\n", pid);
-                               */
+       olderrno = errno;
+       while ((pid = wait3(&w, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) {
+               for (wp = wwindex; wp < &wwindex[NWW]; wp++) {
+                       if (*wp && (*wp)->ww_state == WWS_HASPROC
+                           && (*wp)->ww_pid == pid) {
+                               (*wp)->ww_state = WWS_DEAD;
                                break;
                        }
                }
                                break;
                        }
                }
-               /*
-               if (wp == 0)
-                       wwprintf(curwin, "\r\n%d: No such child\r\n", pid);
-               */
        }
        }
+       errno = olderrno;
 }
 }