1 /*
2 * Check that signal injection works properly.
3 *
4 * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@strace.io>
5 * Copyright (c) 2017-2021 The strace developers.
6 * All rights reserved.
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11 #include "tests.h"
12 #include <signal.h>
13 #include <unistd.h>
14 #include "scno.h"
15
16 static void
17 handler(int sig)
18 {
19 syscall(__NR_exit_group, 0);
20 }
21
22 int
23 main(void)
24 {
25 const struct sigaction act = { .sa_handler = handler };
26 if (sigaction(SIGUSR1, &act, NULL))
27 perror_msg_and_fail("sigaction");
28
29 sigset_t mask;
30 sigemptyset(&mask);
31 sigaddset(&mask, SIGUSR1);
32 if (sigprocmask(SIG_UNBLOCK, &mask, NULL))
33 perror_msg_and_fail("sigprocmask");
34
35 syscall(__NR_chdir, ".");
36 syscall(__NR_exit_group, 1);
37 return 1;
38 }