]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
add commSetCloseOnExec()
authorwessels <>
Sat, 31 Aug 1996 04:36:21 +0000 (04:36 +0000)
committerwessels <>
Sat, 31 Aug 1996 04:36:21 +0000 (04:36 +0000)
src/comm.cc
src/disk.cc

index c309037409f2334f03f7c7582d36989529108d10..a08476c73b8aaec5fb22650b6372ff084ea99751 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.60 1996/08/28 20:11:49 wessels Exp $
+ * $Id: comm.cc,v 1.61 1996/08/30 22:36:21 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -261,12 +261,8 @@ int comm_open(io_type, addr, port, note)
        fd_note(new_socket, note);
     conn->openned = 1;
 
-    if (!(io_type & COMM_NOCLOEXEC)) {
-       if (fcntl(new_socket, F_SETFD, 1) < 0) {
-           debug(5, 0, "comm_open: FD %d: set close-on-exec failed: %s\n",
-               new_socket, xstrerror());
-       }
-    }
+    if (!(io_type & COMM_NOCLOEXEC))
+       commSetCloseOnExec(new_socket);
     if (port > 0) {
        commSetNoLinger(new_socket);
        if (do_reuse)
@@ -471,6 +467,7 @@ int comm_accept(fd, peer, me)
        getsockname(sock, (struct sockaddr *) &M, &Slen);
        *me = M;
     }
+    commSetCloseOnExec(sock);
     /* fdstat update */
     fdstat_open(sock, FD_SOCKET);
     conn = &fd_table[sock];
@@ -970,7 +967,6 @@ static void commSetTcpRcvbuf(fd, size)
            fd, size, xstrerror());
 }
 
-
 int commSetNonBlocking(fd)
      int fd;
 {
@@ -990,6 +986,17 @@ int commSetNonBlocking(fd)
     return 0;
 }
 
+void commSetCloseOnExec(fd)
+     int fd;
+{
+#ifdef FD_CLOEXEC
+    if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
+       debug(5, 0, "comm_open: FD %d: set close-on-exec failed: %s\n",
+           fd, xstrerror());
+    }
+#endif
+}
+
 char **getAddressList(name)
      char *name;
 {
index 629c2e969a911336e56ef8178b6dad5ec3192369..1bd44e1f9bf57ec78c27f21b5110312291478e78 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: disk.cc,v 1.21 1996/08/19 22:46:26 wessels Exp $
+ * $Id: disk.cc,v 1.22 1996/08/30 22:36:28 wessels Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -165,6 +165,7 @@ int file_open(path, handler, mode)
     }
     /* update fdstat */
     fdstat_open(fd, FD_FILE);
+    commSetCloseOnExec(fd);
 
     /* init table */
     strncpy(file_table[fd].filename, path, MAX_FILE_NAME_LEN);