Skip to content

Commit ea37ac0

Browse files
committed
src: ignore ENOTCONN on shutdown race with child
On AIX, OS X and the BSDs, calling shutdown() on one end of a pipe when the other end has closed the connection fails with ENOTCONN. The sequential/test-child-process-execsync test failed sporadically because of a race between the parent and the child where one closed its end of the pipe before the other got around to calling shutdown() on its end of the pipe. Libuv is not the right place to handle that because it can't tell if the ENOTCONN error is genuine but io.js can. Refs: libuv/libuv#268 PR-URL: #1214 Reviewed-By: Bert Belder <bertbelder@gmail.com>
1 parent f06b16f commit ea37ac0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/spawn_sync.cc

+8
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,14 @@ void SyncProcessStdioPipe::WriteCallback(uv_write_t* req, int result) {
321321
void SyncProcessStdioPipe::ShutdownCallback(uv_shutdown_t* req, int result) {
322322
SyncProcessStdioPipe* self =
323323
reinterpret_cast<SyncProcessStdioPipe*>(req->handle->data);
324+
325+
// On AIX, OS X and the BSDs, calling shutdown() on one end of a pipe
326+
// when the other end has closed the connection fails with ENOTCONN.
327+
// Libuv is not the right place to handle that because it can't tell
328+
// if the error is genuine but we here can.
329+
if (result == UV_ENOTCONN)
330+
result = 0;
331+
324332
self->OnShutdownDone(result);
325333
}
326334

0 commit comments

Comments
 (0)