blob: 19f57f14bc73aa0f29f43d2935c45b9317615d0b [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 548bc568f3c735e53fb5b0a5ab6473a3f1457b91 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 7 Aug 2022 14:39:19 -0700
4Subject: [PATCH] check for sys/pidfd.h
5
6This header in newer glibc defines the signatures of functions
7pidfd_send_signal() and pidfd_open() and when these functions are
8defined by libc then we need to include the relevant header to get
9the definitions. Clang 15+ has started to error out when function
10signatures are missing.
11
12Fixes errors like
13misc-utils/kill.c:402:6: error: call to undeclared function 'pidfd_send_signal'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
14 if (pidfd_send_signal(pfd, ctl->numsig, &info, 0) < 0)
15
16Upstream-Status: Submitted [https://github.com/util-linux/util-linux/pull/1769]
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18---
19 configure.ac | 1 +
20 include/pidfd-utils.h | 4 +++-
21 2 files changed, 4 insertions(+), 1 deletion(-)
22
23diff --git a/configure.ac b/configure.ac
24index a511e93de..fd7d9245f 100644
25--- a/configure.ac
26+++ b/configure.ac
27@@ -342,6 +342,7 @@ AC_CHECK_HEADERS([ \
28 sys/mkdev.h \
29 sys/mount.h \
30 sys/param.h \
31+ sys/pidfd.h \
32 sys/prctl.h \
33 sys/resource.h \
34 sys/sendfile.h \
35diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h
36index eddede976..d9e33cbc5 100644
37--- a/include/pidfd-utils.h
38+++ b/include/pidfd-utils.h
39@@ -4,8 +4,10 @@
40 #ifdef HAVE_SYS_SYSCALL_H
41 # include <sys/syscall.h>
42 # if defined(SYS_pidfd_send_signal) && defined(SYS_pidfd_open)
43+# ifdef HAVE_SYS_PIDFD_H
44+# include <sys/pidfd.h>
45+# endif
46 # include <sys/types.h>
47-
48 # ifndef HAVE_PIDFD_SEND_SIGNAL
49 static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
50 unsigned int flags)
51--
522.37.1
53