summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-10 18:40:44 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-11 06:07:20 +0200
commit7f7674fdffbe216f4ee5e7d46fca95e278842ab6 (patch)
treed27b452e8b7211b0b25829839eada2b88fbbaa5f
parentc29605678490614d90c3850438e13c36abc6d12f (diff)
HANDLE_FLAG_INHERIT is set to 0 on internal sockets
On Windows, HANDLE_FLAG_INHERIT is equivalent to O_CLOEXEC on UNIX. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
-rw-r--r--src/ip.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ip.cpp b/src/ip.cpp
index 66177a7..e11ec45 100644
--- a/src/ip.cpp
+++ b/src/ip.cpp
@@ -57,6 +57,13 @@ xs::fd_t xs::open_socket (int domain_, int type_, int protocol_)
errno_assert (rc != -1);
#endif
+ // On Windows, preventing sockets to be inherited by child processes is
+ // done using SetHandleInformation function.
+#if defined XS_HAVE_WINDOWS && defined HANDLE_FLAG_INHERIT
+ BOOL brc = SetHandleInformation ((HANDLE) s, HANDLE_FLAG_INHERIT, 0);
+ win_assert (brc);
+#endif
+
return s;
}