]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/unix/socket.cpp
Implement the required virtual functions in Socket
[libs/net.git] / source / net / unix / socket.cpp
index 02ef7c3c06c4999e7d62ebe838427918271f6d99..a9e9c58362d0f44faad9ae310157ecfd345e5c83 100644 (file)
@@ -15,6 +15,7 @@ namespace Net {
 void Socket::platform_init()
 {
        *priv->event = priv->handle;
+       set_inherit(false);
 }
 
 void Socket::platform_cleanup()
@@ -37,7 +38,13 @@ void Socket::set_platform_events(unsigned)
 void Socket::Private::set_block(bool b)
 {
        int flags = fcntl(handle, F_GETFL);
-       fcntl(handle, F_SETFL, (flags&O_NONBLOCK)|(b?0:O_NONBLOCK));
+       fcntl(handle, F_SETFL, (flags&~O_NONBLOCK)|(b?0:O_NONBLOCK));
+}
+
+void Socket::Private::set_inherit(bool i)
+{
+       int flags = fcntl(handle, F_GETFD);
+       fcntl(handle, F_SETFD, (flags&~O_CLOEXEC)|(i?O_CLOEXEC:0));
 }
 
 int Socket::Private::set_option(int level, int optname, const void *optval, socklen_t optlen)