]> granicus.if.org Git - p11-kit/commitdiff
common: use /proc only on Linux
authorLeonardo Brondani Schenkel <leo@tradeshift.com>
Mon, 28 May 2018 14:18:05 +0000 (16:18 +0200)
committerDaiki Ueno <ueno@gnu.org>
Wed, 12 Sep 2018 12:51:20 +0000 (14:51 +0200)
Non-Linux systems do not have /proc, so do not attempt to open it and
eliminate an unnecessary access() syscall on those systems.

common/compat.c

index f0e31eb0653baed4f70b80032cbb0d7e0f91da7f..5a9702d5c64a1eee78fe52c344cd6b6da82263bc 100644 (file)
@@ -912,6 +912,7 @@ fdwalk (int (* cb) (void *data, int fd),
        struct rlimit rl;
 #endif
 
+#ifdef __linux__
        dir = opendir ("/proc/self/fd");
        if (dir != NULL) {
                while ((de = readdir (dir)) != NULL) {
@@ -934,6 +935,7 @@ fdwalk (int (* cb) (void *data, int fd),
                closedir (dir);
                return res;
        }
+#endif
 
        /* No /proc, brute force */
 #ifdef HAVE_SYS_RESOURCE_H