]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
process_utils: add signal_name() helper
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Nov 2021 09:42:09 +0000 (10:42 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Nov 2021 09:58:35 +0000 (10:58 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
configure.ac
meson.build
src/lxc/process_utils.h

index f7ca355567afb9636222b74df3f0bbb69b471041..0819c8c2a0d82a76200659b70b62ff393a335b90 100644 (file)
@@ -697,7 +697,7 @@ AM_COND_IF([ENABLE_LIBURING],
 AC_HEADER_MAJOR
 
 # Check for some syscalls functions
-AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat gettid memfd_create move_mount open_tree execveat clone3 fsopen fspick fsconfig fsmount openat2 close_range statvfs mount_setattr])
+AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat gettid memfd_create move_mount open_tree execveat clone3 fsopen fspick fsconfig fsmount openat2 close_range statvfs mount_setattr sigdescr_np])
 AC_CHECK_TYPES([__aligned_u64], [], [], [[#include <linux/types.h>]])
 AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]])
 AC_CHECK_TYPES([struct open_how], [], [], [[#include <linux/openat2.h>]])
index 2dbe9e03ff1d1ddf52cca9f65c9971bd883bfbeb..19b3abbc1d392529285245628dbed4d95d8b34c8 100644 (file)
@@ -266,6 +266,7 @@ foreach ident : [
         ['setmntent',          '''#include <stdio.h>
                                   #include <mntent.h>'''],
         ['setns',              '''#include <sched.h>'''],
+        ['sigdescr_np',                '''#include <string.h>'''],
         ['signalfd',           '''#include <sys/signalfd.h>'''],
         ['statx',              '''#include <sys/types.h>
                                   #include <sys/stat.h>
@@ -467,6 +468,7 @@ foreach tuple : [
         ['sethostname'],
         ['setmntent'],
         ['setns'],
+        ['sigdescr_np'],
         ['signalfd'],
         ['statx'],
         ['strlcat'],
index 2eb9e5152e4ef12015220c4cac4a6909a52ab7c6..9c15b15741b9bee25fe1a9ae1760c53e78ce6d83 100644 (file)
@@ -11,6 +11,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/syscall.h>
 #include <unistd.h>
 
@@ -286,4 +287,16 @@ static inline pid_t lxc_raw_gettid(void)
 __hidden extern int lxc_raw_pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
                                              unsigned int flags);
 
+static inline const char *signal_name(int sig)
+{
+       const char *s;
+
+#if HAVE_SIGDESCR_NP
+       s = sigdescr_np(sig);
+#else
+       s = "UNSUPPORTED";
+#endif
+       return s ?: "INVALID_SIGNAL_NUMBER";
+}
+
 #endif /* __LXC_PROCESS_UTILS_H */