]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Use fopen()'s newfangled "e" flag instead of explicit fcntl() calls.
authordes <des@FreeBSD.org>
Fri, 16 Oct 2015 12:53:22 +0000 (12:53 +0000)
committerdes <des@FreeBSD.org>
Fri, 16 Oct 2015 12:53:22 +0000 (12:53 +0000)
PR: 199801
Submitted by: Jukka Ukkonen <jau@iki.fi>
MFC after: 1 week

lib/libfetch/file.c

index 8c1d4042dcc6ae818774ef247e820452ec75ee33..7b6462f5b69cba8d696cdfeba158dd00dedeada2 100644 (file)
@@ -48,7 +48,7 @@ fetchXGetFile(struct url *u, struct url_stat *us, const char *flags)
        if (us && fetchStatFile(u, us, flags) == -1)
                return (NULL);
 
-       f = fopen(u->doc, "r");
+       f = fopen(u->doc, "re");
 
        if (f == NULL) {
                fetch_syserr();
@@ -61,7 +61,6 @@ fetchXGetFile(struct url *u, struct url_stat *us, const char *flags)
                return (NULL);
        }
 
-       fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
        return (f);
 }
 
@@ -77,9 +76,9 @@ fetchPutFile(struct url *u, const char *flags)
        FILE *f;
 
        if (CHECK_FLAG('a'))
-               f = fopen(u->doc, "a");
+               f = fopen(u->doc, "ae");
        else
-               f = fopen(u->doc, "w+");
+               f = fopen(u->doc, "w+e");
 
        if (f == NULL) {
                fetch_syserr();
@@ -92,7 +91,6 @@ fetchPutFile(struct url *u, const char *flags)
                return (NULL);
        }
 
-       fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
        return (f);
 }