2 * Check decoding of sigpending syscall.
4 * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include <asm/unistd.h>
13 #ifdef __NR_sigpending
21 static const char *errstr;
24 k_sigpending(const kernel_ulong_t set)
26 const long rc = syscall(__NR_sigpending, set);
27 errstr = sprintrc(rc);
34 TAIL_ALLOC_OBJECT_CONST_PTR(kernel_ulong_t, k_set);
35 TAIL_ALLOC_OBJECT_CONST_PTR(sigset_t, libc_set);
37 sigemptyset(libc_set);
38 if (sigprocmask(SIG_SETMASK, libc_set, NULL))
39 perror_msg_and_fail("sigprocmask");
41 if (k_sigpending((uintptr_t) libc_set))
42 perror_msg_and_skip("sigpending");
44 puts("sigpending([]) = 0");
46 k_sigpending((uintptr_t) k_set);
47 puts("sigpending([]) = 0");
49 k_sigpending((uintptr_t) (k_set + 1));
50 printf("sigpending(%p) = -1 EFAULT (%m)\n", k_set + 1);
52 uintptr_t efault = sizeof(*k_set) / 2 + (uintptr_t) k_set;
54 printf("sigpending(%#jx) = -1 EFAULT (%m)\n", (uintmax_t) efault);
56 sigaddset(libc_set, SIGHUP);
57 if (sigprocmask(SIG_SETMASK, libc_set, NULL))
58 perror_msg_and_fail("sigprocmask");
61 k_sigpending((uintptr_t) k_set);
62 puts("sigpending([HUP]) = 0");
64 sigaddset(libc_set, SIGINT);
65 if (sigprocmask(SIG_SETMASK, libc_set, NULL))
66 perror_msg_and_fail("sigprocmask");
69 k_sigpending((uintptr_t) k_set);
70 puts("sigpending([HUP INT]) = 0");
72 if (F8ILL_KULONG_SUPPORTED) {
73 k_sigpending(f8ill_ptr_to_kulong(k_set));
74 printf("sigpending(%#jx) = %s\n",
75 (uintmax_t) f8ill_ptr_to_kulong(k_set), errstr);
78 puts("+++ exited with 0 +++");
84 SKIP_MAIN_UNDEFINED("__NR_sigpending")