Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | From 548bc568f3c735e53fb5b0a5ab6473a3f1457b91 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sun, 7 Aug 2022 14:39:19 -0700 |
| 4 | Subject: [PATCH] check for sys/pidfd.h |
| 5 | |
| 6 | This header in newer glibc defines the signatures of functions |
| 7 | pidfd_send_signal() and pidfd_open() and when these functions are |
| 8 | defined by libc then we need to include the relevant header to get |
| 9 | the definitions. Clang 15+ has started to error out when function |
| 10 | signatures are missing. |
| 11 | |
| 12 | Fixes errors like |
| 13 | misc-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 | |
| 16 | Upstream-Status: Submitted [https://github.com/util-linux/util-linux/pull/1769] |
| 17 | Signed-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 | |
| 23 | diff --git a/configure.ac b/configure.ac |
| 24 | index 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 \ |
| 35 | diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h |
| 36 | index 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 | -- |
| 52 | 2.37.1 |
| 53 | |