Skip to content

Commit

Permalink
Mark all socket and file descriptors close-on-exec.
Browse files Browse the repository at this point in the history
PR:		bin/151866
MFC after:	3 weeks
  • Loading branch information
dag-erling committed May 13, 2011
1 parent c827e08 commit 303f143
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/libfetch/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions lib/libfetch/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>

#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>

Expand All @@ -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);
}

Expand Down Expand Up @@ -84,6 +86,7 @@ fetchPutFile(struct url *u, const char *flags)
fetch_syserr();
}

fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
return (f);
}

Expand Down

0 comments on commit 303f143

Please sign in to comment.