close network sockets on fork
authorRobin Gareus <robin@gareus.org>
Fri, 7 Jun 2013 14:54:47 +0000 (16:54 +0200)
committerRobin Gareus <robin@gareus.org>
Fri, 7 Jun 2013 14:54:47 +0000 (16:54 +0200)
fixes problem with external apps (ie. video-server) inheriting them.

libs/midi++2/ipmidi_port.cc
libs/surfaces/osc/osc.cc

index c90a3dbe6fd133a2200c21cf4ce38fd9e92ed2e6..543c63e343dfbe4920fa0005e610584666807fa3 100644 (file)
@@ -160,6 +160,8 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname)
                return false;
        }
 
+       fcntl(sockin, F_SETFD, fcntl(sockin, F_GETFD) | FD_CLOEXEC);
+
        struct sockaddr_in addrin;
        ::memset(&addrin, 0, sizeof(addrin));
        addrin.sin_family = AF_INET;
@@ -206,6 +208,8 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname)
                ::perror("socket(out)");
                return false;
        }
+
+       fcntl(sockout, F_SETFD, fcntl(sockout, F_GETFD) | FD_CLOEXEC);
        
        // Will Hall, Oct 2007
        if (!ifname.empty()) {
index 009587ce85f8009530cfee94571a293299069afa..9e80554f0bf60de159942d06017d1481e6bb2b73 100644 (file)
@@ -166,6 +166,9 @@ OSC::start ()
                _port++;
                continue;
        }
+
+       int fd = lo_server_get_socket_fd (_osc_server);
+       fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
        
 #ifdef ARDOUR_OSC_UNIX_SERVER
        
@@ -174,7 +177,7 @@ OSC::start ()
        // attempt to create unix socket server too
        
        snprintf(tmpstr, sizeof(tmpstr), "/tmp/sooperlooper_XXXXXX");
-       int fd = mkstemp(tmpstr);
+       fd = mkstemp(tmpstr);
        
        if (fd >= 0 ) {
                unlink (tmpstr);
@@ -185,6 +188,8 @@ OSC::start ()
                if (_osc_unix_server) {
                        _osc_unix_socket_path = tmpstr;
                }
+               fd = lo_server_get_socket_fd (_osc_unix_server)
+               fcntl(fdx, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
        }
 #endif