blob: e43e12873fd60fad67d927c04be4a2de2fea3cd5 [file] [log] [blame]
Andrew Geissler4b740dc2020-05-05 08:54:39 -05001From 3cfde0370d3a8949df0c5bcf447cec6692910ed2 Mon Sep 17 00:00:00 2001
2From: Sami Kerola <kerolasa@iki.fi>
3Date: Sat, 15 Feb 2020 21:12:50 +0000
4Subject: [PATCH] kill: include sys/types.h before checking
5 SYS_pidfd_send_signal
6
7Including sys/types.h must happen before SYS_pidfd_send_signal is checked,
8because that header defines variable in normal conditions. When sys/types.h
9does not have SYS_pidfd_send_signal then fallback is defined in config.h
10that is included by default, and has therefore worked fine before and after
11this change.
12
13Upstream-Status: Backport [https://github.com/karelzak/util-linux/commit/3cfde0370d3a8949df0c5bcf447cec6692910ed2]
14
15Signed-off-by: Sami Kerola <kerolasa@iki.fi>
16Signed-off-by: Benjamin Fair <benjaminfair@google.com>
17---
18 include/pidfd-utils.h | 18 ++++++++++--------
19 1 file changed, 10 insertions(+), 8 deletions(-)
20
21diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h
22index 593346576..0baedd2c9 100644
23--- a/include/pidfd-utils.h
24+++ b/include/pidfd-utils.h
25@@ -1,26 +1,28 @@
26 #ifndef UTIL_LINUX_PIDFD_UTILS
27 #define UTIL_LINUX_PIDFD_UTILS
28
29-#if defined(__linux__) && defined(SYS_pidfd_send_signal)
30-# include <sys/types.h>
31+#if defined(__linux__)
32 # include <sys/syscall.h>
33+# if defined(SYS_pidfd_send_signal)
34+# include <sys/types.h>
35
36-# ifndef HAVE_PIDFD_OPEN
37+# ifndef HAVE_PIDFD_OPEN
38 static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
39 unsigned int flags)
40 {
41 return syscall(SYS_pidfd_send_signal, pidfd, sig, info, flags);
42 }
43-# endif
44+# endif
45
46-# ifndef HAVE_PIDFD_SEND_SIGNAL
47+# ifndef HAVE_PIDFD_SEND_SIGNAL
48 static inline int pidfd_open(pid_t pid, unsigned int flags)
49 {
50 return syscall(SYS_pidfd_open, pid, flags);
51 }
52-# endif
53+# endif
54
55-# define UL_HAVE_PIDFD 1
56+# define UL_HAVE_PIDFD 1
57
58-#endif /* __linux__ && SYS_pidfd_send_signal */
59+# endif /* SYS_pidfd_send_signal */
60+#endif /* __linux__ */
61 #endif /* UTIL_LINUX_PIDFD_UTILS */
62--
632.26.1.301.g55bc3eb7cb9-goog
64