Test the correct nonblocking flag in ttylclose(). IO_NDELAY is only valid

in read() and write().  FNONBLOCK is valid in ioctl() and close().

The bug caused hung ptys when a process talked to itself using nonblocking
i/o and exited while the slave pty had output to flush.  ttywait() was
called and hung.  Signals didn't work because the process was exiting.
`comcontrol /dev/ttyp0 drainwait 1' worked to terminate the wait.  This
shows that comcontrol is not limited to hardware control.  It has no i386
or driver dependencies and doesn't belong in src/sbin/i386.

Bruce
This commit is contained in:
Bruce Evans 1995-05-07 06:32:28 +00:00
parent 2b0e7dfa13
commit 65e8f11839

View file

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
* $Id: tty.c,v 1.41 1995/03/29 19:24:46 ache Exp $
* $Id: tty.c,v 1.42 1995/04/15 21:04:58 bde Exp $
*/
#include "snp.h"
@ -1196,7 +1196,7 @@ ttylclose(tp, flag)
int flag;
{
if ((flag & IO_NDELAY) || ttywflush(tp))
if (flag & FNONBLOCK || ttywflush(tp))
ttyflush(tp, FREAD | FWRITE);
return (0);
}