added F_CLOSEM, which might work, too
authorAlan T. DeKok <aland@freeradius.org>
Mon, 26 Sep 2016 12:08:04 +0000 (08:08 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 26 Sep 2016 12:08:04 +0000 (08:08 -0400)
src/lib/misc.c

index be63066..de2b50f 100644 (file)
@@ -1360,6 +1360,12 @@ int closefrom(int fd)
        int i;
        int maxfd = 256;
 
+#ifdef F_CLOSEM
+       if (fcntl(fd, F_CLOSEM) == 0) {
+               return 0;
+       }
+#endif
+
 #ifdef _SC_OPEN_MAX
        maxfd = sysconf(_SC_OPEN_MAX);
        if (maxfd < 0) {
@@ -1371,8 +1377,6 @@ int closefrom(int fd)
 
        /*
         *      FIXME: return EINTR?
-        *
-        *      Use F_CLOSEM?
         */
        for (i = fd; i < maxfd; i++) {
                close(i);