From: wessels <> Date: Sat, 31 Aug 1996 04:36:21 +0000 (+0000) Subject: add commSetCloseOnExec() X-Git-Tag: SQUID_3_0_PRE1~5876 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ca60c8665838e1b280fc3134be1c47950ce638a;p=thirdparty%2Fsquid.git add commSetCloseOnExec() --- diff --git a/src/comm.cc b/src/comm.cc index c309037409..a08476c73b 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -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; { diff --git a/src/disk.cc b/src/disk.cc index 629c2e969a..1bd44e1f9b 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -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);