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 * Restore signals to default behavior. 10f08c3bdfSopenharmony_ci */ 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_ci#include "signal.h" 13f08c3bdfSopenharmony_ci#include "tst_test.h" 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_cistatic int siglist[] = { SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT, 16f08c3bdfSopenharmony_ci SIGBUS, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2, SIGPIPE, SIGALRM, 17f08c3bdfSopenharmony_ci SIGTERM, SIGCHLD, SIGCONT, SIGTSTP, SIGTTIN, 18f08c3bdfSopenharmony_ci SIGTTOU, SIGURG, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, 19f08c3bdfSopenharmony_ci SIGWINCH, SIGIO, SIGPWR, SIGSYS 20f08c3bdfSopenharmony_ci}; 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_cistatic void sighandler(int sig LTP_ATTRIBUTE_UNUSED) 23f08c3bdfSopenharmony_ci{ 24f08c3bdfSopenharmony_ci} 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_cistatic void do_test(unsigned int n) 27f08c3bdfSopenharmony_ci{ 28f08c3bdfSopenharmony_ci sighandler_t rval, first; 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_ci SAFE_SIGNAL(siglist[n], SIG_DFL); 31f08c3bdfSopenharmony_ci first = SAFE_SIGNAL(siglist[n], sighandler); 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_ci SAFE_SIGNAL(siglist[n], SIG_DFL); 34f08c3bdfSopenharmony_ci rval = SAFE_SIGNAL(siglist[n], sighandler); 35f08c3bdfSopenharmony_ci 36f08c3bdfSopenharmony_ci if (rval == first) { 37f08c3bdfSopenharmony_ci tst_res(TPASS, "signal(%d) restore succeeded " 38f08c3bdfSopenharmony_ci "received %p.", siglist[n], rval); 39f08c3bdfSopenharmony_ci } else { 40f08c3bdfSopenharmony_ci tst_res(TFAIL, "return values for signal(%d) don't match. " 41f08c3bdfSopenharmony_ci "Got %p, expected %p.", 42f08c3bdfSopenharmony_ci siglist[n], rval, first); 43f08c3bdfSopenharmony_ci } 44f08c3bdfSopenharmony_ci} 45f08c3bdfSopenharmony_ci 46f08c3bdfSopenharmony_cistatic struct tst_test test = { 47f08c3bdfSopenharmony_ci .tcnt = ARRAY_SIZE(siglist), 48f08c3bdfSopenharmony_ci .test = do_test, 49f08c3bdfSopenharmony_ci}; 50