From 67645f1d63ff2829c6543ccc146e1af1fee63c7d Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 28 Sep 2014 12:46:51 +0100 Subject: [PATCH] Set sockets to be specifically non-inheritable * This means if a process with a remote connection creates a child process we don't have the socket stay open zombie-like. --- renderdoc/os/win32/win32_network.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/renderdoc/os/win32/win32_network.cpp b/renderdoc/os/win32/win32_network.cpp index bcaf4c9c6..0f3eba59b 100644 --- a/renderdoc/os/win32/win32_network.cpp +++ b/renderdoc/os/win32/win32_network.cpp @@ -28,6 +28,10 @@ #include "os/os_specific.h" +#ifndef WSA_FLAG_NO_HANDLE_INHERIT +#define WSA_FLAG_NO_HANDLE_INHERIT 0x80 +#endif + namespace Network { @@ -227,7 +231,7 @@ bool Socket::RecvDataBlocking(void *buf, uint32_t length) Socket *CreateServerSocket(const char *bindaddr, uint16_t port, int queuesize) { - SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + SOCKET s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_NO_HANDLE_INHERIT); if(s == INVALID_SOCKET) return NULL; @@ -277,7 +281,7 @@ Socket *CreateClientSocket(const wchar_t *host, uint16_t port, int timeoutMS) for(addrinfoW *ptr = result; ptr != NULL; ptr = ptr->ai_next) { - SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + SOCKET s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_NO_HANDLE_INHERIT); if(s == INVALID_SOCKET) return NULL;