[comp.bugs.4bsd] Bug in select

siegel@hc.DSPO.GOV (Josh Siegel) (11/20/87)

There seems to be a bug in select.  If a person tells a tty
to stop (^S), select will still return that there is data
in the tty even while it won't send any of it.  This causes
programs that depend on select to multiplex to go block
on reading that tty.

The reason is the following...

When I stop a tty, the following routine is called:

	.
	.
	.
   if ((tp->t_state&TS_TTSTOP) == 0) {
                        tp->t_state |= TS_TTSTOP;
                        (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
                }
	.
	.
	.


The select looks like:

        case FREAD:
                nread = ttnread(tp);
                if ((nread > 0) || ((tp->t_state & TS_CARR_ON) == 0))
                        goto win;
                if (tp->t_rsel && tp->t_rsel->p_wchan == (caddr_t)&selwait)
                        tp->t_state |= TS_RCOLL;
                else
                        tp->t_rsel = u.u_procp;
                break;
	.
	.
	.
	return(0);
win:
	return(1);

I see no check in the select routine to see if the tty is stopped.  As
far as I am concerned, the file descripter is not ready for reading
while it is stopped.    Any comments?

			--Josh Siegel
-- 
Josh Siegel		(siegel@hc.dspo.gov)
  Friends don't let Friends eat Cherry Zingers