1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) International Business Machines Corp., 2001 4 * Author: Wayne Boyer 5 * Copyright (c) Linux Test Project, 2002-2022 6 */ 7 8 /*\ 9 * [Description] 10 * 11 * Verify that SIGALRM signal scheduled by alarm() in the parent process 12 * is not delivered to the child process. 13 */ 14 15 #include <stdlib.h> 16 #include "tst_test.h" 17 18 static volatile int alarm_cnt; 19 verify_alarm(void)20static void verify_alarm(void) 21 { 22 pid_t pid; 23 24 alarm_cnt = 0; 25 26 TST_EXP_PASS_SILENT(alarm(1)); 27 pid = SAFE_FORK(); 28 29 sleep(3); 30 31 if (pid == 0) { 32 TST_EXP_EQ_LU(alarm_cnt, 0); 33 exit(0); 34 } 35 36 TST_EXP_EQ_LU(alarm_cnt, 1); 37 } 38 sighandler(int sig LTP_ATTRIBUTE_UNUSED)39static void sighandler(int sig LTP_ATTRIBUTE_UNUSED) 40 { 41 alarm_cnt++; 42 } 43 setup(void)44static void setup(void) 45 { 46 SAFE_SIGNAL(SIGALRM, sighandler); 47 } 48 49 static struct tst_test test = { 50 .test_all = verify_alarm, 51 .setup = setup, 52 .forks_child = 1, 53 }; 54