diff options
author | Christopher Faylor <me@cgf.cx> | 2007-07-29 17:24:54 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2007-07-29 17:24:54 +0000 |
commit | 5990b3399cf1871368ea9c60840b42cdb187ef06 (patch) | |
tree | cda4336d89202965a63889ae3041c6833b267b10 /winsup/cygwin/fhandler.cc | |
parent | 9d017bd09cf60644db45802bb2e5fd5ffaed619a (diff) | |
download | cygnal-5990b3399cf1871368ea9c60840b42cdb187ef06.tar.gz cygnal-5990b3399cf1871368ea9c60840b42cdb187ef06.tar.bz2 cygnal-5990b3399cf1871368ea9c60840b42cdb187ef06.zip |
* fhandler.cc (fhandler_base::wait_overlapped): Handle read EOF better and
issue a SIGPIPE when we get ERROR_NO_DATA.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r-- | winsup/cygwin/fhandler.cc | 27 |
1 files changed, 21 insertions, 6 deletions
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; } |