util: add debug messages to UTI_FdSetCloexec()
This commit is contained in:
parent
3038047f9b
commit
622769cdfd
2 changed files with 11 additions and 5 deletions
1
socket.c
1
socket.c
|
@ -187,7 +187,6 @@ open_socket(int domain, int type, int flags)
|
||||||
(socket_flags & SOCK_CLOEXEC) == 0 &&
|
(socket_flags & SOCK_CLOEXEC) == 0 &&
|
||||||
#endif
|
#endif
|
||||||
!UTI_FdSetCloexec(sock_fd)) {
|
!UTI_FdSetCloexec(sock_fd)) {
|
||||||
DEBUG_LOG("Could not set O_CLOEXEC : %s", strerror(errno));
|
|
||||||
close(sock_fd);
|
close(sock_fd);
|
||||||
return INVALID_SOCK_FD;
|
return INVALID_SOCK_FD;
|
||||||
}
|
}
|
||||||
|
|
15
util.c
15
util.c
|
@ -888,12 +888,19 @@ UTI_FdSetCloexec(int fd)
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
flags = fcntl(fd, F_GETFD);
|
flags = fcntl(fd, F_GETFD);
|
||||||
if (flags != -1) {
|
if (flags == -1) {
|
||||||
flags |= FD_CLOEXEC;
|
DEBUG_LOG("fcntl() failed : %s", strerror(errno));
|
||||||
return !fcntl(fd, F_SETFD, flags);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
flags |= FD_CLOEXEC;
|
||||||
|
|
||||||
|
if (fcntl(fd, F_SETFD, flags) < 0) {
|
||||||
|
DEBUG_LOG("fcntl() failed : %s", strerror(errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
Loading…
Reference in a new issue