fix ctrl macro for ANSI C
[unix-history] / usr / src / usr.bin / window / wwchild.c
index ede17f4..2971166 100644 (file)
@@ -1,8 +1,15 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wwchild.c  3.4 %G%";
+static char sccsid[] = "@(#)wwchild.c  3.7 %G%";
 #endif
 
 #endif
 
+/*
+ * Copyright (c) 1983 Regents of the University of California,
+ * All rights reserved.  Redistribution permitted subject to
+ * the terms of the Berkeley Software License Agreement.
+ */
+
 #include "ww.h"
 #include "ww.h"
+#include <sys/types.h>
 #include <sys/wait.h>
 
 wwchild()
 #include <sys/wait.h>
 
 wwchild()
@@ -12,6 +19,7 @@ wwchild()
        register struct ww **wp;
        union wait w;
        int pid;
        register struct ww **wp;
        union wait w;
        int pid;
+       char collected = 0;
 
        olderrno = errno;
        while ((pid = wait3(&w, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) {
 
        olderrno = errno;
        while ((pid = wait3(&w, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) {
@@ -19,9 +27,13 @@ wwchild()
                        if (*wp && (*wp)->ww_state == WWS_HASPROC
                            && (*wp)->ww_pid == pid) {
                                (*wp)->ww_state = WWS_DEAD;
                        if (*wp && (*wp)->ww_state == WWS_HASPROC
                            && (*wp)->ww_pid == pid) {
                                (*wp)->ww_state = WWS_DEAD;
+                               collected = 1;
                                break;
                        }
                }
        }
        errno = olderrno;
                                break;
                        }
                }
        }
        errno = olderrno;
+       /* jump out of wwiomux when somebody dies */
+       if (collected)
+               wwsetintr();
 }
 }