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 <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
Brad King 2017-04-08 19:14:51 -04:00 committed by Ben Noordhuis
parent 6398251aff
commit 2e197418c3

View File

@ -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);