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