]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/socket.cpp
Mark sockets as close-on-exec upon creation on Linux
[libs/net.git] / source / net / socket.cpp
index 84db6375c5c7b96c0db0a211e6ff201f527a0c49..2a1a71c0a4b3aa404b616f09a7be6e1799660c27 100644 (file)
@@ -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();
 }