summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.tests/unix/cloexec/cloexec.cpp4
-rw-r--r--src/network/socket/qnet_unix_p.h4
2 files changed, 8 insertions, 0 deletions
diff --git a/config.tests/unix/cloexec/cloexec.cpp b/config.tests/unix/cloexec/cloexec.cpp
index 3f127d8d3f..cbde307237 100644
--- a/config.tests/unix/cloexec/cloexec.cpp
+++ b/config.tests/unix/cloexec/cloexec.cpp
@@ -44,6 +44,10 @@ int main()
(void) pipe2(pipes, O_CLOEXEC | O_NONBLOCK);
(void) fcntl(0, F_DUPFD_CLOEXEC, 0);
(void) dup3(0, 3, O_CLOEXEC);
+#if defined(__NetBSD__)
+ (void) paccept(0, 0, 0, NULL, SOCK_CLOEXEC | SOCK_NONBLOCK);
+#else
(void) accept4(0, 0, 0, SOCK_CLOEXEC | SOCK_NONBLOCK);
+#endif
return 0;
}
diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h
index 9626c53711..1481f565d4 100644
--- a/src/network/socket/qnet_unix_p.h
+++ b/src/network/socket/qnet_unix_p.h
@@ -109,7 +109,11 @@ static inline int qt_safe_accept(int s, struct sockaddr *addr, QT_SOCKLEN_T *add
int sockflags = SOCK_CLOEXEC;
if (flags & O_NONBLOCK)
sockflags |= SOCK_NONBLOCK;
+# if defined(Q_OS_NETBSD)
+ fd = ::paccept(s, addr, static_cast<QT_SOCKLEN_T *>(addrlen), NULL, sockflags);
+# else
fd = ::accept4(s, addr, static_cast<QT_SOCKLEN_T *>(addrlen), sockflags);
+# endif
return fd;
#else
fd = ::accept(s, addr, static_cast<QT_SOCKLEN_T *>(addrlen));