1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) Crackerjack Project., 2007 4f08c3bdfSopenharmony_ci * Copyright (c) Manas Kumar Nayak maknayak@in.ibm.com> 5f08c3bdfSopenharmony_ci * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com> 6f08c3bdfSopenharmony_ci */ 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ci/*\ 9f08c3bdfSopenharmony_ci * [Description] 10f08c3bdfSopenharmony_ci * 11f08c3bdfSopenharmony_ci * Test that waitid() fails with ECHILD with process that is not child of the 12f08c3bdfSopenharmony_ci * current process. We fork() one child just to be sure that there are unwaited 13f08c3bdfSopenharmony_ci * for children available while the test runs. 14f08c3bdfSopenharmony_ci */ 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci#include <stdlib.h> 17f08c3bdfSopenharmony_ci#include <sys/wait.h> 18f08c3bdfSopenharmony_ci#include "tst_test.h" 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_cistatic siginfo_t *infop; 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_cistatic void run(void) 23f08c3bdfSopenharmony_ci{ 24f08c3bdfSopenharmony_ci if (!SAFE_FORK()) 25f08c3bdfSopenharmony_ci exit(0); 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci TST_EXP_FAIL(waitid(P_PID, 1, infop, WEXITED), ECHILD); 28f08c3bdfSopenharmony_ci} 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_cistatic struct tst_test test = { 31f08c3bdfSopenharmony_ci .test_all = run, 32f08c3bdfSopenharmony_ci .forks_child = 1, 33f08c3bdfSopenharmony_ci .bufs = (struct tst_buffers[]) { 34f08c3bdfSopenharmony_ci {&infop, .size = sizeof(*infop)}, 35f08c3bdfSopenharmony_ci {} 36f08c3bdfSopenharmony_ci } 37f08c3bdfSopenharmony_ci}; 38