]> git.0d.be Git - empathy.git/commitdiff
Add CLOEXEC flag on BaconMessageConnection FD. Fixes bug #533840.
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 23 May 2008 16:53:24 +0000 (16:53 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 23 May 2008 16:53:24 +0000 (16:53 +0000)
svn path=/trunk/; revision=1124

src/bacon-message-connection.c

index c755cd5d28b23815d9ba6d910aad0b04bbc11276..c9fda4aeb77dafdecdaa7963a27d2cfcdf8a5845 100644 (file)
@@ -101,8 +101,18 @@ static gboolean server_cb (GIOChannel *source,
 static gboolean
 setup_connection (BaconMessageConnection *conn)
 {
+       int fdflags;
+
        g_return_val_if_fail (conn->chan == NULL, FALSE);
 
+       /* Add CLOEXEC flag on the fd to make sure the socket get closed
+        * if exec is called. */
+       fdflags = fcntl (conn->fd, F_GETFD, 0);
+       if (fdflags >= 0) {
+               fdflags |= FD_CLOEXEC;
+               fcntl (conn->fd, F_SETFD, fdflags);
+       }
+
        conn->chan = g_io_channel_unix_new (conn->fd);
        if (!conn->chan) {
                return FALSE;
@@ -269,9 +279,7 @@ try_server (BaconMessageConnection *conn)
        }
        listen (conn->fd, 5);
 
-       if (!setup_connection (conn))
-               return FALSE;
-       return TRUE;
+       return setup_connection (conn);
 }
 
 static gboolean