From 17f94796a9b3c4f1ff28829107a82107dcb362b4 Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Thu, 3 Nov 2022 18:24:53 +0100 Subject: [PATCH] fix pifd_open check Replace AC_CHECK_FUNC by AC_CHECK_FUNCS otherwise HAVE_PIDFD_OPEN will never be defined resulting in the following build failure if pidfd_open is available but __NR_pidfd_open is not available: pgrep.c: In function 'pidfd_open': pgrep.c:748:17: error: '__NR_pidfd_open' undeclared (first use in this function); did you mean 'pidfd_open'? 748 | return syscall(__NR_pidfd_open, pid, flags); | ^~~~~~~~~~~~~~~ | pidfd_open This build failure is raised since the addition of pwait in version 3.3.17 and https://gitlab.com/procps-ng/procps/-/commit/c8384e682c1cfb3b2dc797e0f8a3cbaaccf7a3da Fixes: - http://autobuild.buildroot.org/results/f23a5156e641b2ebdd673973dec0f9c87760c688 Signed-off-by: Fabrice Fontaine --- configure.ac | 2 +- src/pgrep.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 629881a6..1a3ccdb8 100644 --- a/configure.ac +++ b/configure.ac @@ -160,7 +160,7 @@ AC_TRY_COMPILE([#include ], AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) -AC_CHECK_FUNC([pidfd_open], [enable_pidwait=yes], [ +AC_CHECK_FUNCS([pidfd_open], [enable_pidwait=yes], [ AC_MSG_CHECKING([for __NR_pidfd_open]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include diff --git a/src/pgrep.c b/src/pgrep.c index c4ad5da3..1c15981c 100644 --- a/src/pgrep.c +++ b/src/pgrep.c @@ -38,9 +38,11 @@ #include #include -#if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN) +#ifdef ENABLE_PIDWAIT #include +#ifndef HAVE_PIDFD_OPEN #include +#endif /* !HAVE_PIDFD_OPEN */ #endif /* EXIT_SUCCESS is 0 */