1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 4f08c3bdfSopenharmony_ci * Author: Richard Logan 5f08c3bdfSopenharmony_ci * Copyright (c) Linux Test Project, 2001-2022 6f08c3bdfSopenharmony_ci */ 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ci/*\ 9f08c3bdfSopenharmony_ci * [Description] 10f08c3bdfSopenharmony_ci * 11f08c3bdfSopenharmony_ci * Verify that alarms created by alarm() are not inherited by children 12f08c3bdfSopenharmony_ci * created via fork. 13f08c3bdfSopenharmony_ci */ 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_ci#include <stdlib.h> 16f08c3bdfSopenharmony_ci#include "tst_test.h" 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_cistatic void verify_alarm(void) 19f08c3bdfSopenharmony_ci{ 20f08c3bdfSopenharmony_ci pid_t pid; 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci TST_EXP_PASS_SILENT(alarm(100)); 23f08c3bdfSopenharmony_ci 24f08c3bdfSopenharmony_ci pid = SAFE_FORK(); 25f08c3bdfSopenharmony_ci if (pid == 0) { 26f08c3bdfSopenharmony_ci TST_EXP_PASS(alarm(0), "alarm(0) in child process"); 27f08c3bdfSopenharmony_ci exit(0); 28f08c3bdfSopenharmony_ci } 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_ci TST_EXP_VAL(alarm(0), 100, "alarm(0) in parent process"); 31f08c3bdfSopenharmony_ci} 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_cistatic struct tst_test test = { 34f08c3bdfSopenharmony_ci .test_all = verify_alarm, 35f08c3bdfSopenharmony_ci .forks_child = 1, 36f08c3bdfSopenharmony_ci}; 37