diff --git a/src/shared_func.h b/src/shared_func.h index d935d07..2aba889 100644 --- a/src/shared_func.h +++ b/src/shared_func.h @@ -730,7 +730,7 @@ int fd_add_flags(int fd, int adding_flags); * fd: the fd to set * return: error no , 0 success, != 0 fail */ -#define set_nonblock(fd) fd_add_flags(fd, O_NONBLOCK) +#define set_nonblock(fd) fd_add_flags(fd, O_NONBLOCK | FD_CLOEXEC) /** set fd FD_CLOEXEC flags * parameters: diff --git a/src/sockopt.c b/src/sockopt.c index 0f0b38d..8d04797 100644 --- a/src/sockopt.c +++ b/src/sockopt.c @@ -2126,7 +2126,7 @@ int tcpsetnonblockopt(int fd) return errno != 0 ? errno : EACCES; } - if (fcntl(fd, F_SETFL, flags | (O_NONBLOCK | O_CLOEXEC)) < 0) + if (fcntl(fd, F_SETFL, flags | (O_NONBLOCK | FD_CLOEXEC)) < 0) { logError("file: "__FILE__", line: %d, " \ "fcntl failed, errno: %d, error info: %s.", \