summaryrefslogtreecommitdiff
path: root/ext/socket/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/init.c')
-rw-r--r--ext/socket/init.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 44228d3..33ddc05 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -497,7 +497,11 @@ cloexec_accept(int socket, struct sockaddr *address, socklen_t *address_len)
if (address_len) len0 = *address_len;
#ifdef HAVE_ACCEPT4
if (try_accept4) {
- ret = accept4(socket, address, address_len, SOCK_CLOEXEC);
+ int flags = 0;
+#ifdef SOCK_CLOEXEC
+ flags |= SOCK_CLOEXEC;
+#endif
+ ret = accept4(socket, address, address_len, flags);
/* accept4 is available since Linux 2.6.28, glibc 2.10. */
if (ret != -1) {
if (ret <= 2)