From 15b68c63bb0acb05ad27aeeedb167cfad820e0cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 13 May 2011 07:21:41 +0000 Subject: [PATCH] Mark all socket and file descriptors close-on-exec. PR: bin/151866 MFC after: 3 weeks --- lib/libfetch/common.c | 1 + lib/libfetch/file.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index ff10d27b419..fefc4c5defd 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -213,6 +213,7 @@ fetch_reopen(int sd) /* allocate and fill connection structure */ if ((conn = calloc(1, sizeof(*conn))) == NULL) return (NULL); + fcntl(sd, F_SETFD, FD_CLOEXEC); conn->sd = sd; ++conn->ref; return (conn); diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c index a1492ba0563..dffaad8278f 100644 --- a/lib/libfetch/file.c +++ b/lib/libfetch/file.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -57,6 +58,7 @@ fetchXGetFile(struct url *u, struct url_stat *us, const char *flags) fetch_syserr(); } + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); return (f); } @@ -84,6 +86,7 @@ fetchPutFile(struct url *u, const char *flags) fetch_syserr(); } + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); return (f); }