aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/pipe.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-11-03 05:42:21 +0000
committerChristopher Faylor <me@cgf.cx>2001-11-03 05:42:21 +0000
commitc41570695a46cf3a4f1cf3f72db353c963f40f7e (patch)
treec46d10c143594b112016b62f07ddfa3d3d79a85f /winsup/cygwin/pipe.cc
parent243a041bd0164aa62813ac4ba5a1a02eb2db455b (diff)
downloadnewlib-c41570695a46cf3a4f1cf3f72db353c963f40f7e.zip
newlib-c41570695a46cf3a4f1cf3f72db353c963f40f7e.tar.gz
newlib-c41570695a46cf3a4f1cf3f72db353c963f40f7e.tar.bz2
* fhandler.cc (fhandler_base::read): Return just read ahead characters if slow
device. * fhandler.h (fhandler_base::set_eof): New virtual method. (fhandler_pipe::set_eof): New method. * pipe.cc (fhandler_pipe::fhandler_pipe): Clear saweof flag. (fhandler_pipe::read): Return immediately if hit eof. (fhandler_pipe::hit_eof): Return true if saweof flag is set. * select.cc (peek_pipe): Don't call PeekNamedPipe if we couldn't grab the guard mutex.
Diffstat (limited to 'winsup/cygwin/pipe.cc')
-rw-r--r--winsup/cygwin/pipe.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 904dbd2..87d226b 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -26,7 +26,7 @@ static unsigned pipecount;
static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u";
fhandler_pipe::fhandler_pipe (DWORD devtype)
- : fhandler_base (devtype), guard (NULL), writepipe_exists(0),
+ : fhandler_base (devtype), guard (NULL), saweof (false), writepipe_exists(0),
orig_pid (0), id (0)
{
}
@@ -52,8 +52,10 @@ fhandler_pipe::set_close_on_exec (int val)
int __stdcall
fhandler_pipe::read (void *in_ptr, size_t in_len)
{
+ if (hit_eof ())
+ return 0;
int res = this->fhandler_base::read (in_ptr, in_len);
- ReleaseMutex (guard);
+ (void) ReleaseMutex (guard);
return res;
}
@@ -72,6 +74,8 @@ fhandler_pipe::hit_eof ()
{
char buf[80];
HANDLE ev;
+ if (saweof)
+ return 1;
if (!orig_pid)
return false;
__small_sprintf (buf, pipeid_fmt, orig_pid, id);