From 9d41b029e940bacf17a3c8d7cc06162f0a41b70a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 11 Dec 2022 17:59:16 +0200 Subject: [PATCH] Mark sockets as close-on-exec upon creation on Linux --- source/net/socket.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/net/socket.cpp b/source/net/socket.cpp index 84db637..2a1a71c 100644 --- a/source/net/socket.cpp +++ b/source/net/socket.cpp @@ -29,8 +29,13 @@ Socket::Socket(Family af, int type, int proto): { mode = IO::M_RDWR; - // TODO use SOCK_CLOEXEC on Linux +#ifdef __linux__ + type |= SOCK_CLOEXEC; +#endif priv->handle = socket(family_to_sys(af), type, proto); +#ifndef __linux__ + set_inherit(false); +#endif platform_init(); } -- 2.43.0