From 11791631501109f475dfd1cfe6019883ce4c3d2a Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Sat, 16 Dec 2017 10:09:38 +0900 Subject: [PATCH] Add O_CLOEXEC for some posix platform --- source/eventcore/drivers/posix/sockets.d | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/eventcore/drivers/posix/sockets.d b/source/eventcore/drivers/posix/sockets.d index 0a3d6f1..bcb7f10 100644 --- a/source/eventcore/drivers/posix/sockets.d +++ b/source/eventcore/drivers/posix/sockets.d @@ -20,6 +20,15 @@ version (Posix) { version (linux) enum SO_REUSEPORT = 15; else enum SO_REUSEPORT = 0x200; + + static if (!is(typeof(O_CLOEXEC))) + { + version (linux) enum O_CLOEXEC = 0x80000; + else version (FreeBSD) enum O_CLOEXEC = 0x100000; + else version (NetBSD) enum O_CLOEXEC = 0x400000; + else version (OpenBSD) enum O_CLOEXEC = 0x10000; + else version (OSX) enum O_CLOEXEC = 0x1000000; + } } version (linux) { extern (C) int accept4(int sockfd, sockaddr *addr, socklen_t *addrlen, int flags) nothrow @nogc;