[LTP] [PATCH 1/2] lapi/pidfd: adding pidfd header file

Li Wang liwang@redhat.com
Fri Aug 5 08:34:00 CEST 2022


The newer Glibc already provided wrapper for the series pidfd syscall,
so let's include the header file conditionally.

  # rpm -q glibc-devel
  glibc-devel-2.35.9000-31.fc37.ppc64le

  # rpm -ql glibc-devel | grep pidfd
  /usr/include/sys/pidfd.h

To get rid of compiling error from fedora-rawhide:

  tst_safe_macros.c: In function ‘safe_pidfd_open’:
  tst_safe_macros.c:135:16: error: implicit declaration of function ‘pidfd_open’ [-Werror=implicit-function-declaration]
  135 |         rval = pidfd_open(pid, flags);
      |                ^~~~~~~~~~

Signed-off-by: Li Wang <liwang@redhat.com>
---
 configure.ac         | 1 +
 include/lapi/pidfd.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/configure.ac b/configure.ac
index 69b145b5f..d50ec1ea7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,7 @@ AC_CHECK_HEADERS_ONCE([ \
     sys/epoll.h \
     sys/fanotify.h \
     sys/inotify.h \
+    sys/pidfd.h
     sys/prctl.h \
     sys/shm.h \
     sys/timerfd.h \
diff --git a/include/lapi/pidfd.h b/include/lapi/pidfd.h
index 244d3acaf..9ca8e5aa2 100644
--- a/include/lapi/pidfd.h
+++ b/include/lapi/pidfd.h
@@ -8,6 +8,9 @@
 #define LAPI_PIDFD_H__
 
 #include <fcntl.h>
+#ifdef HAVE_SYS_PIDFD_H
+# include <sys/pidfd.h>
+#endif
 #include "config.h"
 #include "lapi/syscalls.h"
 
-- 
2.35.3



More information about the ltp mailing list