unix: fix error handling in uv__make_socketpair()
This commit checks that setting the close-on-exec flag on the file descriptors succeeds, and closes the file descriptors when it fails. PR-URL: https://github.com/libuv/libuv/pull/2665 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
ab6fc15a16
commit
06616db362
@ -119,11 +119,20 @@ static int uv__make_socketpair(int fds[2]) {
|
||||
|
||||
return 0;
|
||||
#else
|
||||
int err;
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds))
|
||||
return UV__ERR(errno);
|
||||
|
||||
uv__cloexec(fds[0], 1);
|
||||
uv__cloexec(fds[1], 1);
|
||||
err = uv__cloexec(fds[0], 1);
|
||||
if (err == 0)
|
||||
err = uv__cloexec(fds[1], 1);
|
||||
|
||||
if (err != 0) {
|
||||
uv__close(fds[0]);
|
||||
uv__close(fds[1]);
|
||||
return UV__ERR(errno);
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user