/*-------- Date: Wed, 14 Jan 87 16:14:00 pst From: sd%chem@sdcsvax.ucsd.edu (Steve Dempsey) Message-Id: <8701150014.AA22673@sdchemf.chem.ucsd.arpa> To: info-iris@sumex-aim.stanford.edu Subject: tty input bugs in the 3.5 kernel I've found a couple of bugs with tty input in the 3.5 kernel. We are running the standard TCP/IP kernel on a 2400 Turbo (ser. #547). I've included a couple of simple test programs which demonstrate the problems. These programs run correctly on a VAX 750 (4.3BSD) and a Celerity 1260D (4.2BSD). I've reported these problems to the HOTLINE. The console, a direct connect terminal, and remote network terminals all exhibit the same behavior. --------*/ ------------------------- first cut here-------------------------- /* * This test monitors the count returned by the FIONREAD ioctl. * Note that the count changes as you enter or delete characters. * This seems to indicate that the count is for the RAW input queue. * * Previous SGI systems (and all other UNIX based machines we have) * return the count for the CANONICAL input queue ****! * * The problem this creates occurs whe you are polling for tty input * and the user enters a line containing only a newline character. * The count for the raw queue goes to 1, but since the newline is the * end-of-line character it is moved almost immediately from the raw queue * to the canonical queue, so the count for the raw queue goes back to zero. * If the ioctl does not occur during the very short period while the newline * is still in the raw queue you will never know the newline was entered. */ #include #include main() { int lastcnt, ccnt; int readline(); lastcnt = 1000000; while(1) { ioctl(0, FIONREAD, &ccnt); if(ccnt != lastcnt) { printf("ioctl reports %d chars in input.\n", ccnt); lastcnt = ccnt; } sleep(1); } } ------------------------------------cut again here ---------------------- /* * This test shows the incorrect behavior of a read of tty input. * While the program is sleeping enter multiple lines of text. * When the read is executed all lines are read, not just the first one. */ #include main() { int nc; char lbuf[100]; sleep(10); nc = read(0, lbuf, sizeof lbuf); lbuf[nc] = 0; printf("nc=%d, read=%s", nc, lbuf); } -------------------------- last cut here -----------------------------------