Skip to content

Commit

Permalink
src: ignore ENOTCONN on shutdown race with child
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bnoordhuis committed Mar 28, 2015
1 parent f06b16f commit ea37ac0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/spawn_sync.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,14 @@ void SyncProcessStdioPipe::WriteCallback(uv_write_t* req, int result) {
void SyncProcessStdioPipe::ShutdownCallback(uv_shutdown_t* req, int result) {
SyncProcessStdioPipe* self =
reinterpret_cast<SyncProcessStdioPipe*>(req->handle->data);

// 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.
// Libuv is not the right place to handle that because it can't tell
// if the error is genuine but we here can.
if (result == UV_ENOTCONN)
result = 0;

self->OnShutdownDone(result);
}

Expand Down

0 comments on commit ea37ac0

Please sign in to comment.