From 2e197418c3ece95922dc3c32a5a6d4f014a3a844 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 8 Apr 2017 19:14:51 -0400 Subject: [PATCH] cygwin: recognize EOF on named pipe closure On Cygwin a named pipe closed by terminating a child process may be reported via `ECONNRESET` on the next read. Teach `uv__read` to interpret this as end of file. This fixes the `spawn_and_kill_with_std` test. PR-URL: https://github.com/libuv/libuv/pull/1312 Reviewed-By: Ben Noordhuis Reviewed-By: Santiago Gimeno --- src/unix/stream.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/unix/stream.c b/src/unix/stream.c index c1ec4866..77c5cfab 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -1173,6 +1173,11 @@ static void uv__read(uv_stream_t* stream) { uv__stream_osx_interrupt_select(stream); } stream->read_cb(stream, 0, &buf); +#if defined(__CYGWIN__) || defined(__MSYS__) + } else if (errno == ECONNRESET && stream->type == UV_NAMED_PIPE) { + uv__stream_eof(stream, &buf); + return; +#endif } else { /* Error. User should call uv_close(). */ stream->read_cb(stream, -errno, &buf);