xref: /original-bsd/usr.bin/window/wwiomux.c (revision 8251a00e)
1 #ifndef lint
2 static	char *sccsid = "@(#)wwiomux.c	3.1 83/08/11";
3 #endif
4 
5 #include "ww.h"
6 
7 wwforce(imask)
8 register int *imask;
9 {
10 	register struct ww **w;
11 	char buf[512];
12 	register int n;
13 
14 	for (w = wwindex; w < &wwindex[NWW]; w++)
15 		if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0)
16 			*imask |= 1 << (*w)->ww_pty;
17 	n = select(wwdtablesize, imask, (int *)0, (int *)0,
18 		(struct timeval *)0);
19 	if (n <= 0)
20 		return -1;
21 	for (w = wwindex; w < &wwindex[NWW]; w++)
22 		if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0
23 		    && *imask & 1 << (*w)->ww_pty) {
24 			n = read((*w)->ww_pty, buf, sizeof buf);
25 			if (n > 0)
26 				(void) wwwrite((*w), buf, n);
27 		}
28 	return 0;
29 }
30