From fc42885d0ebb877864f989a0a78ed3b4125448aa Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 11 Jan 2013 13:39:28 +0100 Subject: [PATCH] unix: set closed fd to -1, avoid double close bugs * abort() if close() fails * set fd to -1 after close() to prevent double close bugs --- src/unix/process.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/unix/process.c b/src/unix/process.c index 3beb575b..4c5714fa 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -232,8 +232,11 @@ static int uv__process_open_stream(uv_stdio_container_t* container, if (!(container->flags & UV_CREATE_PIPE) || pipefds[0] < 0) return 0; - assert(pipefds[1] >= 0); - close(pipefds[1]); + if (close(pipefds[1])) + if (errno != EINTR && errno != EINPROGRESS) + abort(); + + pipefds[1] = -1; uv__nonblock(pipefds[0], 1); if (container->data.stream->type == UV_NAMED_PIPE &&