unix: fix potential bug if dup2 fails in uv_spawn
PR-URL: https://github.com/libuv/libuv/pull/309 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
009bbad4e7
commit
09cdc923c2
@ -319,7 +319,12 @@ static void uv__process_child_init(const uv_process_options_t* options,
|
|||||||
if (fd == use_fd)
|
if (fd == use_fd)
|
||||||
uv__cloexec(use_fd, 0);
|
uv__cloexec(use_fd, 0);
|
||||||
else
|
else
|
||||||
dup2(use_fd, fd);
|
fd = dup2(use_fd, fd);
|
||||||
|
|
||||||
|
if (fd == -1) {
|
||||||
|
uv__write_int(error_fd, -errno);
|
||||||
|
_exit(127);
|
||||||
|
}
|
||||||
|
|
||||||
if (fd <= 2)
|
if (fd <= 2)
|
||||||
uv__nonblock(fd, 0);
|
uv__nonblock(fd, 0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user