From: utzoo!decvax!cca!z Newsgroups: net.bugs.4bsd Title: FIONREAD bug Article-I.D.: cca.1829 Posted: Fri Jul 16 12:57:27 1982 Received: Sat Jul 17 02:16:01 1982 The FIONREAD ioctl works properly when used on slave pty's, but not on controller pty's; it erroneously always returns zero. The reason is that the character count for the controller pty is located in a different place from where FIONREAD expects it. The following code corrects this. There are a number of places this code can be put; we put it right after the first statement in ptyioctl (the statement which sets up tp). if (cdevsw[major(dev)].d_open == ptcopen && cmd == FIONREAD) { off_t nread; nread = tp->t_outq.c_cc; if (copyout((caddr_t)&nread, addr, sizeof (off_t))) u.u_error = EFAULT; return; }