Mark all socket and file descriptors close-on-exec.

PR:		bin/151866
MFC after:	3 weeks
This commit is contained in:
Dag-Erling Smørgrav 2011-05-13 07:21:41 +00:00
parent 3d08a76bbc
commit 15b68c63bb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=221830
2 changed files with 4 additions and 0 deletions

View file

@ -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);

View file

@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
@ -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);
}