1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) International Business Machines Corp., 2001
4*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2012 Cyril Hrubis <[email protected]>
5*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) Linux Test Project, 2001-2015
6*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2023 Ioannis Bonatakis <[email protected]>
7*49cdfc7eSAndroid Build Coastguard Worker */
8*49cdfc7eSAndroid Build Coastguard Worker
9*49cdfc7eSAndroid Build Coastguard Worker /*\
10*49cdfc7eSAndroid Build Coastguard Worker * [Description]
11*49cdfc7eSAndroid Build Coastguard Worker *
12*49cdfc7eSAndroid Build Coastguard Worker * Check for ECHILD errno when call wait4(2) with an invalid pid value.
13*49cdfc7eSAndroid Build Coastguard Worker */
14*49cdfc7eSAndroid Build Coastguard Worker
15*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
16*49cdfc7eSAndroid Build Coastguard Worker #include <sys/wait.h>
17*49cdfc7eSAndroid Build Coastguard Worker
18*49cdfc7eSAndroid Build Coastguard Worker static pid_t pid_max;
19*49cdfc7eSAndroid Build Coastguard Worker
run(void)20*49cdfc7eSAndroid Build Coastguard Worker static void run(void)
21*49cdfc7eSAndroid Build Coastguard Worker {
22*49cdfc7eSAndroid Build Coastguard Worker int status;
23*49cdfc7eSAndroid Build Coastguard Worker struct rusage rusage;
24*49cdfc7eSAndroid Build Coastguard Worker
25*49cdfc7eSAndroid Build Coastguard Worker TST_EXP_FAIL2(wait4(pid_max + 1, &status, 0, &rusage), ECHILD);
26*49cdfc7eSAndroid Build Coastguard Worker }
27*49cdfc7eSAndroid Build Coastguard Worker
setup(void)28*49cdfc7eSAndroid Build Coastguard Worker static void setup(void)
29*49cdfc7eSAndroid Build Coastguard Worker {
30*49cdfc7eSAndroid Build Coastguard Worker SAFE_FILE_SCANF("/proc/sys/kernel/pid_max", "%d\n", &pid_max);
31*49cdfc7eSAndroid Build Coastguard Worker }
32*49cdfc7eSAndroid Build Coastguard Worker
33*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
34*49cdfc7eSAndroid Build Coastguard Worker .test_all = run,
35*49cdfc7eSAndroid Build Coastguard Worker .setup = setup,
36*49cdfc7eSAndroid Build Coastguard Worker };
37