]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/unix/socket.cpp
Use size_t to represent sizes
[libs/net.git] / source / net / unix / socket.cpp
index 02ef7c3c06c4999e7d62ebe838427918271f6d99..b8cc580f0040f7f16c1bf8adbc4668dce5a2c6ec 100644 (file)
@@ -9,12 +9,15 @@
 #include "socket.h"
 #include "socket_private.h"
 
+using namespace std;
+
 namespace Msp {
 namespace Net {
 
 void Socket::platform_init()
 {
        *priv->event = priv->handle;
+       set_inherit(false);
 }
 
 void Socket::platform_cleanup()
@@ -37,7 +40,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?0:O_CLOEXEC));
 }
 
 int Socket::Private::set_option(int level, int optname, const void *optval, socklen_t optlen)
@@ -51,7 +60,7 @@ int Socket::Private::get_option(int level, int optname, void *optval, socklen_t
 }
 
 
-unsigned check_sys_error(int ret, const char *func)
+size_t check_sys_error(make_signed<size_t>::type ret, const char *func)
 {
        if(ret<0)
        {