From: Mikko Rasa Date: Sun, 11 Dec 2022 15:59:16 +0000 (+0200) Subject: Mark sockets as close-on-exec upon creation on Linux X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9d41b029e940bacf17a3c8d7cc06162f0a41b70a;p=libs%2Fnet.git Mark sockets as close-on-exec upon creation on Linux --- 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(); }