From f5934323090bfa4c07b5b6a7f4c9eb3f419868e7 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Mon, 28 Dec 2015 02:22:43 +0100 Subject: [PATCH 2/2] maint: avoid sc_prohibit_always_true_header_tests failure. To: address@hidden * configure.ac: Check for getrlimit function directly rather than the "sys/resource.h" header file. * lib/fdleak.c: Include "sys/resource.h" when HAVE_GETRLIMIT is set. (get_max_fd): s/HAVE_GETRUSAGE/HAVE_GETRLIMIT/. --- configure.ac | 2 +- lib/fdleak.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3db4827..df8882a 100644 --- a/configure.ac +++ b/configure.ac @@ -142,7 +142,7 @@ dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(sys/param.h mntent.h sys/mnttab.h sys/mntio.h sys/mkdev.h) dnl fdleak.c needs sys/resource.h because it calls getrlimit(2). -AC_CHECK_HEADERS(sys/resource.h) +AC_CHECK_FUNCS(getrlimit) AC_HEADER_MAJOR dnl TODO: it's possible gnulib eliminates the need for AC_HEADER_DIRENT. AC_HEADER_DIRENT diff --git a/lib/fdleak.c b/lib/fdleak.c index c22d299..2e6c9a9 100644 --- a/lib/fdleak.c +++ b/lib/fdleak.c @@ -26,7 +26,7 @@ #include #include #include -#if defined HAVE_SYS_RESOURCE_H +#if HAVE_GETRLIMIT # include #endif #include @@ -120,7 +120,7 @@ get_max_fd (void) open_max = _POSIX_OPEN_MAX; /* underestimate */ /* We assume if RLIMIT_NOFILE is defined, all the related macros are, too. */ -#if defined HAVE_GETRUSAGE && defined RLIMIT_NOFILE +#if defined HAVE_GETRLIMIT && defined RLIMIT_NOFILE if (0 == getrlimit (RLIMIT_NOFILE, &fd_limit)) { if (fd_limit.rlim_cur == RLIM_INFINITY) -- 2.1.4