Set FD_CLOEXEC in a little convenience function that does the right thing
[u/mdw/putty] / unix / uxnet.c
index d01a44d..e1dfce3 100644 (file)
@@ -470,6 +470,8 @@ static int try_connect(Actual_Socket sock)
        goto ret;
     }
 
+    cloexec(s);
+
     if (sock->oobinline) {
        int b = TRUE;
        setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (void *) &b, sizeof(b));
@@ -723,6 +725,8 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i
        return (Socket) ret;
     }
 
+    cloexec(s);
+
     ret->oobinline = 0;
 
     setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));