Skip to content
This repository
Browse code

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...
commit fc42885d0ebb877864f989a0a78ed3b4125448aa 1 parent 2ec2a51
Ben Noordhuis bnoordhuis authored

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. +5 2 src/unix/process.c
7 src/unix/process.c
@@ -232,8 +232,11 @@ static int uv__process_open_stream(uv_stdio_container_t* container,
232 232 if (!(container->flags & UV_CREATE_PIPE) || pipefds[0] < 0)
233 233 return 0;
234 234
235   - assert(pipefds[1] >= 0);
236   - close(pipefds[1]);
  235 + if (close(pipefds[1]))
  236 + if (errno != EINTR && errno != EINPROGRESS)
  237 + abort();
  238 +
  239 + pipefds[1] = -1;
237 240 uv__nonblock(pipefds[0], 1);
238 241
239 242 if (container->data.stream->type == UV_NAMED_PIPE &&

0 comments on commit fc42885

Please sign in to comment.
Something went wrong with that request. Please try again.