]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Actually use the cloexec argument in the !defined(SOCK_CLOEXEC) case
authorNick Mathewson <nickm@torproject.org>
Fri, 2 Aug 2013 14:04:21 +0000 (10:04 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 2 Aug 2013 14:04:21 +0000 (10:04 -0400)
src/common/compat.c

index af8f2884dcf5efa56756d2a084db6106c8f3ba66..8aab12a30efcd56eec8984cd1f917cd26db558d9 100644 (file)
@@ -1084,10 +1084,12 @@ tor_open_socket_with_extensions(int domain, int type, int protocol,
     return s;
 
 #if defined(FD_CLOEXEC)
-  if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1) {
-    log_warn(LD_FS,"Couldn't set FD_CLOEXEC: %s", strerror(errno));
-    tor_close_socket_simple(s);
-    return TOR_INVALID_SOCKET;
+  if (cloexec) {
+    if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1) {
+      log_warn(LD_FS,"Couldn't set FD_CLOEXEC: %s", strerror(errno));
+      tor_close_socket_simple(s);
+      return TOR_INVALID_SOCKET;
+    }
   }
 #endif