|
|
@ -36,8 +36,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "os-compatibility.h" |
|
|
|
#include "os-compatibility.h" |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
int |
|
|
|
set_cloexec_or_close(int fd) |
|
|
|
os_fd_set_cloexec(int fd) |
|
|
|
{ |
|
|
|
{ |
|
|
|
long flags; |
|
|
|
long flags; |
|
|
|
|
|
|
|
|
|
|
@ -46,17 +46,23 @@ set_cloexec_or_close(int fd) |
|
|
|
|
|
|
|
|
|
|
|
flags = fcntl(fd, F_GETFD); |
|
|
|
flags = fcntl(fd, F_GETFD); |
|
|
|
if (flags == -1) |
|
|
|
if (flags == -1) |
|
|
|
goto err; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) |
|
|
|
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) |
|
|
|
goto err; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
return fd; |
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
err: |
|
|
|
static int |
|
|
|
|
|
|
|
set_cloexec_or_close(int fd) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (os_fd_set_cloexec(fd) != 0) { |
|
|
|
close(fd); |
|
|
|
close(fd); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return fd; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int |
|
|
|
int |
|
|
|
os_socketpair_cloexec(int domain, int type, int protocol, int *sv) |
|
|
|
os_socketpair_cloexec(int domain, int type, int protocol, int *sv) |
|
|
|