From 59807dbff1759e7549e99dd669cf70e38c063cd6 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Sat, 4 Jun 2005 13:57:08 +0000 Subject: [PATCH] - Added an error/EOF check in the input drain loop. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14972 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/termios_tcflush.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/termios_tcflush.c b/library/termios_tcflush.c index c9f9254..08a6003 100755 --- a/library/termios_tcflush.c +++ b/library/termios_tcflush.c @@ -1,5 +1,5 @@ /* - * $Id: termios_tcflush.c,v 1.1 2005-06-04 10:46:21 obarthel Exp $ + * $Id: termios_tcflush.c,v 1.2 2005-06-04 13:57:08 obarthel Exp $ * * :ts=4 * @@ -79,6 +79,8 @@ tcflush(int file_descriptor,int queue) if(queue == TCIFLUSH || queue == TCIOFLUSH) { + LONG num_bytes_read; + /* Set raw mode so we can read without blocking. */ if(FLAG_IS_SET(tios->c_lflag,ICANON)) { @@ -92,7 +94,10 @@ tcflush(int file_descriptor,int queue) if(__check_abort_enabled) __check_abort(); - Read(fd->fd_DefaultFile,buf,64); /* Read away available data. (upto 8k) */ + /* Read away available data. (upto 8k) */ + num_bytes_read = Read(fd->fd_DefaultFile,buf,64); + if(num_bytes_read == ERROR || num_bytes_read == 0) + break; } /* Restore the Raw/Cooked mode. */