xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/signal/signal03.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker  *   Copyright (c) International Business Machines  Corp., 2001
4*49cdfc7eSAndroid Build Coastguard Worker  */
5*49cdfc7eSAndroid Build Coastguard Worker 
6*49cdfc7eSAndroid Build Coastguard Worker /*\
7*49cdfc7eSAndroid Build Coastguard Worker  * [Description]
8*49cdfc7eSAndroid Build Coastguard Worker  *
9*49cdfc7eSAndroid Build Coastguard Worker  * Set signals to be ignored.
10*49cdfc7eSAndroid Build Coastguard Worker  */
11*49cdfc7eSAndroid Build Coastguard Worker 
12*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
13*49cdfc7eSAndroid Build Coastguard Worker 
14*49cdfc7eSAndroid Build Coastguard Worker static int siglist[] = { SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT, SIGIOT,
15*49cdfc7eSAndroid Build Coastguard Worker 	SIGBUS, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2, SIGPIPE, SIGALRM,
16*49cdfc7eSAndroid Build Coastguard Worker 	SIGTERM,
17*49cdfc7eSAndroid Build Coastguard Worker #ifdef SIGSTKFLT
18*49cdfc7eSAndroid Build Coastguard Worker 	SIGSTKFLT,
19*49cdfc7eSAndroid Build Coastguard Worker #endif
20*49cdfc7eSAndroid Build Coastguard Worker 	SIGCHLD, SIGCONT, SIGTSTP, SIGTTIN,
21*49cdfc7eSAndroid Build Coastguard Worker 	SIGTTOU, SIGURG, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF,
22*49cdfc7eSAndroid Build Coastguard Worker 	SIGWINCH, SIGIO, SIGPWR, SIGSYS,
23*49cdfc7eSAndroid Build Coastguard Worker #ifdef SIGUNUSED
24*49cdfc7eSAndroid Build Coastguard Worker 	SIGUNUSED
25*49cdfc7eSAndroid Build Coastguard Worker #endif
26*49cdfc7eSAndroid Build Coastguard Worker };
27*49cdfc7eSAndroid Build Coastguard Worker 
28*49cdfc7eSAndroid Build Coastguard Worker static volatile int ign_handler;
29*49cdfc7eSAndroid Build Coastguard Worker 
sighandler(int sig LTP_ATTRIBUTE_UNUSED)30*49cdfc7eSAndroid Build Coastguard Worker static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
31*49cdfc7eSAndroid Build Coastguard Worker {
32*49cdfc7eSAndroid Build Coastguard Worker 	ign_handler = 1;
33*49cdfc7eSAndroid Build Coastguard Worker }
34*49cdfc7eSAndroid Build Coastguard Worker 
do_test(unsigned int n)35*49cdfc7eSAndroid Build Coastguard Worker static void do_test(unsigned int n)
36*49cdfc7eSAndroid Build Coastguard Worker {
37*49cdfc7eSAndroid Build Coastguard Worker 	pid_t pid;
38*49cdfc7eSAndroid Build Coastguard Worker 
39*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_SIGNAL(siglist[n], sighandler);
40*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_SIGNAL(siglist[n], SIG_IGN);
41*49cdfc7eSAndroid Build Coastguard Worker 
42*49cdfc7eSAndroid Build Coastguard Worker 	pid = getpid();
43*49cdfc7eSAndroid Build Coastguard Worker 
44*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_KILL(pid, siglist[n]);
45*49cdfc7eSAndroid Build Coastguard Worker 	TST_EXP_EQ_SSZ(ign_handler, 0);
46*49cdfc7eSAndroid Build Coastguard Worker }
47*49cdfc7eSAndroid Build Coastguard Worker 
48*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
49*49cdfc7eSAndroid Build Coastguard Worker 	.tcnt = ARRAY_SIZE(siglist),
50*49cdfc7eSAndroid Build Coastguard Worker 	.test = do_test,
51*49cdfc7eSAndroid Build Coastguard Worker };
52