static char sccsid
[] = "@(#)wwiomux.c 3.14 %G%";
* Copyright (c) 1983 Regents of the University of California,
* All rights reserved. Redistribution permitted subject to
* the terms of the Berkeley Software License Agreement.
* Multiple window output handler.
* The idea is to copy window outputs to the terminal, via the
* display package. We try to give the top most window highest
* priority. The only return condition is when there is keyboard
* input, which is serviced asynchronously by wwrint().
* When there's nothing to do, we sleep in a select().
* This can be done better with interrupt driven io. But that's
* not supported on ptys, yet.
* The history of this routine is interesting.
static struct timeval tv
= { 0, 0 };
for (w
= wwhead
.ww_forw
; w
!= &wwhead
; w
= w
->ww_forw
) {
if (w
->ww_obq
< w
->ww_obe
)
if (w
->ww_obq
> w
->ww_obp
&& !w
->ww_stopped
)
n
= select(wwdtablesize
, &imask
, (int *)0, (int *)0,
noblock
? &tv
: (struct timeval
*)0);
for (w
= wwhead
.ww_forw
; w
!= &wwhead
; w
= w
->ww_forw
) {
if (w
->ww_pty
< 0 || (imask
& 1 << w
->ww_pty
) == 0)
n
= read(w
->ww_pty
, p
, w
->ww_obe
- p
);
} else if (!w
->ww_ispty
) {
} else if (*p
== TIOCPKT_DATA
) {
if (*p
& TIOCPKT_FLUSHWRITE
) {
w
->ww_obq
= w
->ww_obp
= w
->ww_ob
;
for (w
= wwhead
.ww_forw
; w
!= &wwhead
; w
= w
->ww_forw
)
if (w
->ww_pty
>= 0 && w
->ww_obq
> w
->ww_obp
&& !w
->ww_stopped
) {
n
= wwwrite(w
, w
->ww_obp
, w
->ww_obq
- w
->ww_obp
);
if ((w
->ww_obp
+= n
) == w
->ww_obq
)
w
->ww_obq
= w
->ww_obp
= w
->ww_ob
;