Permalink
Browse files

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
  • Loading branch information...
1 parent 2ec2a51 commit fc42885d0ebb877864f989a0a78ed3b4125448aa @bnoordhuis bnoordhuis committed Jan 11, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/unix/process.c
View
@@ -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 &&

0 comments on commit fc42885

Please sign in to comment.