]> granicus.if.org Git - strace/blob - tests/check_sigign.c
8e8fadfee35a871ec762203403d1cd7a57dbf6e6
[strace] / tests / check_sigign.c
1 /*
2  * Check that the signal handler for the specified signal number is set
3  * to SIG_IGN/SIG_DFL.
4  *
5  * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
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 <stdlib.h>
14
15 int
16 main(int ac, char **av)
17 {
18         if (ac != 3)
19                 error_msg_and_fail("usage: check_sigign 0|1 signum");
20
21         const int ign = !!atoi(av[1]);
22         const int signum = atoi(av[2]);
23         struct sigaction act;
24
25         if (sigaction(signum, NULL, &act))
26                 perror_msg_and_fail("sigaction: %s", av[2]);
27
28         return ign ^ (act.sa_handler == SIG_IGN);
29 }