aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-11-30 22:23:01 +0000
committerChristopher Faylor <me@cgf.cx>2002-11-30 22:23:01 +0000
commit4f96ae699cb92dbc12ea7e3b8e27df029f655176 (patch)
tree8c75cb7c50fec1006b40172e0a506ba10c31570a
parent73593ea1dde79ae684806254b083da6c0e746673 (diff)
downloadnewlib-4f96ae699cb92dbc12ea7e3b8e27df029f655176.zip
newlib-4f96ae699cb92dbc12ea7e3b8e27df029f655176.tar.gz
newlib-4f96ae699cb92dbc12ea7e3b8e27df029f655176.tar.bz2
* fhandler_tty.cc (fhandler_pty_master::accept_input): Move read_retval
assignment to prevent race condition. Remove read_retval from return statement.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/fhandler_tty.cc13
2 files changed, 15 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e3642bf..bec423b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2002-11-29 Steve Osborn <bub@io.com>
+
+ * fhandler_tty.cc (fhandler_pty_master::accept_input): Move
+ read_retval assignment to prevent race condition. Remove read_retval
+ from return statement.
+
2002-11-29 Christopher Faylor <cgf@redhat.com>
* pinfo.h (winpids::set): Renamed from init.
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index ed10927..dc0f0fc 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -153,7 +153,6 @@ fhandler_pty_master::accept_input ()
rc = WaitForSingleObject (input_mutex, INFINITE);
bytes_left = n = eat_readahead (-1);
- get_ttyp ()->read_retval = 0;
p = rabuf;
if (n != 0)
@@ -165,9 +164,12 @@ fhandler_pty_master::accept_input ()
if (!rc)
{
debug_printf ("error writing to pipe %E");
+ get_ttyp ()->read_retval = -1;
break;
}
- get_ttyp ()->read_retval += written;
+ else
+ get_ttyp ()->read_retval = 1;
+
p += written;
bytes_left -= written;
if (bytes_left > 0)
@@ -181,10 +183,13 @@ fhandler_pty_master::accept_input ()
}
}
else
- termios_printf ("sending EOF to slave");
+ {
+ termios_printf ("sending EOF to slave");
+ get_ttyp ()->read_retval = 0;
+ }
SetEvent (input_available_event);
ReleaseMutex (input_mutex);
- return get_ttyp ()->read_retval;
+ return 1;
}
static DWORD WINAPI