From: Simon Marlow Date: Wed, 15 Sep 2010 14:18:09 +0000 (+0000) Subject: errno corresponding to ERROR_NO_DATA should be EPIPE (non-threaded RTS) X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=0cbb1f34579da2b3ba8e199c3a95f6312710659f errno corresponding to ERROR_NO_DATA should be EPIPE (non-threaded RTS) --- diff --git a/rts/win32/IOManager.c b/rts/win32/IOManager.c index 81dedda..c9a759f 100644 --- a/rts/win32/IOManager.c +++ b/rts/win32/IOManager.c @@ -16,6 +16,7 @@ #include #include #include +#include /* * Internal state maintained by the IO manager. @@ -181,7 +182,15 @@ IOWorkerProc(PVOID param) len = write(work->workData.ioData.fd, work->workData.ioData.buf, work->workData.ioData.len); - if (len == -1) { errCode = errno; } + if (len == -1) { + errCode = errno; + // write() gets errno wrong for + // ERROR_NO_DATA, we have to fix it here: + if (errCode == EINVAL && + GetLastError() == ERROR_NO_DATA) { + errCode = EPIPE; + } + } } complData = work->workData.ioData.buf; fd = work->workData.ioData.fd;