unix: handle uv__open_cloexec return value correctly

`uv__open_cloexec()` already returns a libuv error code in case
of failure, and not `-1` like syscalls do.

Fixes: https://github.com/nodejs/help/issues/2099
PR-URL: https://github.com/libuv/libuv/pull/2645
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
This commit is contained in:
Anna Henningsen 2020-01-21 14:02:33 +01:00
parent 8249bd19cf
commit 02e7a78628
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
2 changed files with 3 additions and 3 deletions

View File

@ -990,7 +990,7 @@ static uint64_t uv__read_proc_meminfo(const char* what) {
rc = 0;
fd = uv__open_cloexec("/proc/meminfo", O_RDONLY);
if (fd == -1)
if (fd < 0)
return 0;
n = read(fd, buf, sizeof(buf) - 1);

View File

@ -37,8 +37,8 @@ int uv__random_readpath(const char* path, void* buf, size_t buflen) {
fd = uv__open_cloexec(path, O_RDONLY);
if (fd == -1)
return UV__ERR(errno);
if (fd < 0)
return fd;
if (fstat(fd, &s)) {
uv__close(fd);