From 7f7674fdffbe216f4ee5e7d46fca95e278842ab6 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 10 Apr 2012 18:40:44 +0200 Subject: 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 --- src/ip.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') 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; } -- cgit v1.2.3