1From 0cce3e981540c28d2f703b9ab16c04d0df8fa03d Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Thu, 3 Nov 2022 18:24:53 +0100
4Subject: [PATCH] fix pifd_open check
5
6Replace AC_CHECK_FUNC by AC_CHECK_FUNCS otherwise HAVE_PIDFD_OPEN will
7never be defined resulting in the following build failure if pidfd_open
8is available but __NR_pidfd_open is not available:
9
10pgrep.c: In function 'pidfd_open':
11pgrep.c:748:17: error: '__NR_pidfd_open' undeclared (first use in this function); did you mean 'pidfd_open'?
12  748 |  return syscall(__NR_pidfd_open, pid, flags);
13      |                 ^~~~~~~~~~~~~~~
14      |                 pidfd_open
15
16This build failure is raised since the addition of pwait in version
173.3.17 and
18https://gitlab.com/procps-ng/procps/-/commit/c8384e682c1cfb3b2dc797e0f8a3cbaaccf7a3da
19
20Fixes:
21 - http://autobuild.buildroot.org/results/f23a5156e641b2ebdd673973dec0f9c87760c688
22
23Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
24[Upstream status:
25https://gitlab.com/procps-ng/procps/-/merge_requests/166]
26---
27 configure.ac | 2 +-
28 src/pgrep.c  | 2 +-
29 2 files changed, 2 insertions(+), 2 deletions(-)
30
31diff --git a/configure.ac b/configure.ac
32index 629881a6..1a3ccdb8 100644
33--- a/configure.ac
34+++ b/configure.ac
35@@ -160,7 +160,7 @@ AC_TRY_COMPILE([#include <errno.h>],
36 		AC_MSG_RESULT(yes),
37 		AC_MSG_RESULT(no))
38
39-AC_CHECK_FUNC([pidfd_open], [enable_pwait=yes], [
40+AC_CHECK_FUNCS([pidfd_open], [enable_pwait=yes], [
41   AC_MSG_CHECKING([for __NR_pidfd_open])
42   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
43 #include <sys/syscall.h>
44diff --git a/pgrep.c b/pgrep.c
45index c4ad5da3..29cfedf7 100644
46--- a/pgrep.c
47+++ b/pgrep.c
48@@ -38,7 +38,7 @@
49 #include <stdbool.h>
50 #include <time.h>
51
52-#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN)
53+#if defined(ENABLE_PWAIT)
54 #include <sys/epoll.h>
55 #include <sys/syscall.h>
56 #endif
57--
582.35.1
59
60