* fhandler.cc (fhandler_base::wait_overlapped): Handle read EOF better and

issue a SIGPIPE when we get ERROR_NO_DATA.
This commit is contained in:
Christopher Faylor 2007-07-29 17:24:54 +00:00
parent 9d017bd09c
commit 5990b3399c
2 changed files with 26 additions and 6 deletions

View File

@ -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> 2007-07-29 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Don't allow * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Don't allow

View File

@ -1699,8 +1699,15 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
{ {
if (bytes) if (bytes)
*bytes = (DWORD) -1; *bytes = (DWORD) -1;
if (!res && GetLastError () != ERROR_IO_PENDING) DWORD err = GetLastError ();
__seterrno (); if (!res && err != ERROR_IO_PENDING)
{
if (err != ERROR_HANDLE_EOF && err != ERROR_BROKEN_PIPE)
goto err;
res = 1;
if (*bytes)
*bytes = 0;
}
else else
{ {
#ifdef DEBUGGING #ifdef DEBUGGING
@ -1723,8 +1730,8 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
res = 1; res = 1;
else else
{ {
__seterrno (); err = GetLastError ();
res = -1; goto err;
} }
break; break;
case WAIT_OBJECT_0 + 1: case WAIT_OBJECT_0 + 1:
@ -1733,11 +1740,19 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
res = 0; res = 0;
break; break;
default: default:
__seterrno (); err = GetLastError ();
res = -1; goto err;
break; break;
} }
} }
goto out;
err:
__seterrno_from_win_error (err);
res = -1;
if (err == ERROR_NO_DATA)
raise (SIGPIPE);
out:
ResetEvent (get_overlapped ()->hEvent); ResetEvent (get_overlapped ()->hEvent);
return res; return res;
} }