Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2007-07-29 21:24:54 +0400
committerChristopher Faylor <me@cgf.cx>2007-07-29 21:24:54 +0400
commit5990b3399cf1871368ea9c60840b42cdb187ef06 (patch)
treecda4336d89202965a63889ae3041c6833b267b10
parent9d017bd09cf60644db45802bb2e5fd5ffaed619a (diff)
* fhandler.cc (fhandler_base::wait_overlapped): Handle read EOF better and
issue a SIGPIPE when we get ERROR_NO_DATA.
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/fhandler.cc27
2 files changed, 26 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index dfb3e7890..26d4c5255 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-29 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * fhandler.cc (fhandler_base::wait_overlapped): Handle read EOF better
+ and issue a SIGPIPE when we get ERROR_NO_DATA.
+
2007-07-29 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Don't allow
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index efe2aa665..16f87a765 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1699,8 +1699,15 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
{
if (bytes)
*bytes = (DWORD) -1;
- if (!res && GetLastError () != ERROR_IO_PENDING)
- __seterrno ();
+ DWORD err = GetLastError ();
+ if (!res && err != ERROR_IO_PENDING)
+ {
+ if (err != ERROR_HANDLE_EOF && err != ERROR_BROKEN_PIPE)
+ goto err;
+ res = 1;
+ if (*bytes)
+ *bytes = 0;
+ }
else
{
#ifdef DEBUGGING
@@ -1723,8 +1730,8 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
res = 1;
else
{
- __seterrno ();
- res = -1;
+ err = GetLastError ();
+ goto err;
}
break;
case WAIT_OBJECT_0 + 1:
@@ -1733,11 +1740,19 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
res = 0;
break;
default:
- __seterrno ();
- res = -1;
+ err = GetLastError ();
+ goto err;
break;
}
}
+ goto out;
+
+err:
+ __seterrno_from_win_error (err);
+ res = -1;
+ if (err == ERROR_NO_DATA)
+ raise (SIGPIPE);
+out:
ResetEvent (get_overlapped ()->hEvent);
return res;
}