Commit | Line | Data |
---|---|---|
abbfd2f2 | 1 | #ifndef lint |
cc9d6cd0 | 2 | static char *sccsid = "@(#)wwiomux.c 3.4 83/10/27"; |
abbfd2f2 EW |
3 | #endif |
4 | ||
5 | #include "ww.h" | |
6 | ||
7 | wwforce(imask) | |
8 | register int *imask; | |
9 | { | |
bb05dfb5 | 10 | register struct ww **w; |
abbfd2f2 EW |
11 | char buf[512]; |
12 | register int n; | |
abbfd2f2 | 13 | |
bb05dfb5 EW |
14 | for (w = wwindex; w < &wwindex[NWW]; w++) |
15 | if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0) | |
16 | *imask |= 1 << (*w)->ww_pty; | |
ec8d5bfb EW |
17 | if (*imask == 0) |
18 | return -1; | |
bb05dfb5 EW |
19 | n = select(wwdtablesize, imask, (int *)0, (int *)0, |
20 | (struct timeval *)0); | |
ec8d5bfb | 21 | if (n <= 0) |
abbfd2f2 | 22 | return -1; |
bb05dfb5 EW |
23 | for (w = wwindex; w < &wwindex[NWW]; w++) |
24 | if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0 | |
25 | && *imask & 1 << (*w)->ww_pty) { | |
26 | n = read((*w)->ww_pty, buf, sizeof buf); | |
cc9d6cd0 EW |
27 | if (n < 0) { |
28 | (*w)->ww_haspty = 0; | |
29 | (void) close((*w)->ww_pty); | |
30 | (void) close((*w)->ww_tty); | |
31 | } else if (n > 0) | |
bb05dfb5 | 32 | (void) wwwrite((*w), buf, n); |
abbfd2f2 | 33 | } |
abbfd2f2 EW |
34 | return 0; |
35 | } |