last few day's work
[unix-history] / usr / src / usr.bin / window / wwiomux.c
index 02a36d4..dd2517c 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwiomux.c   1.2 83/07/17";
+static char *sccsid = "@(#)wwiomux.c   3.1 83/08/11";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -7,22 +7,23 @@ static        char *sccsid = "@(#)wwiomux.c   1.2 83/07/17";
 wwforce(imask)
 register int *imask;
 {
 wwforce(imask)
 register int *imask;
 {
-       register struct ww *w;
+       register struct ww **w;
        char buf[512];
        register int n;
 
        char buf[512];
        register int n;
 
-       for (w = wwhead; w; w = w->ww_next)
-               *imask |= 1 << w->ww_pty;
-       n = select(getdtablesize(), imask,
-               (int *)0, (int *)0, (struct timeval *)0);
+       for (w = wwindex; w < &wwindex[NWW]; w++)
+               if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0)
+                       *imask |= 1 << (*w)->ww_pty;
+       n = select(wwdtablesize, imask, (int *)0, (int *)0,
+               (struct timeval *)0);
        if (n <= 0)
                return -1;
        if (n <= 0)
                return -1;
-       for (w = wwhead; w; w = w->ww_next) {
-               if (*imask & 1<<w->ww_pty) {
-                       n = read(w->ww_pty, buf, sizeof buf);
+       for (w = wwindex; w < &wwindex[NWW]; w++)
+               if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0
+                   && *imask & 1 << (*w)->ww_pty) {
+                       n = read((*w)->ww_pty, buf, sizeof buf);
                        if (n > 0)
                        if (n > 0)
-                               wwwrite(w, buf, n);
+                               (void) wwwrite((*w), buf, n);
                }
                }
-       }
        return 0;
 }
        return 0;
 }