• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) Crackerjack Project., 2007
4  * Copyright (c) Manas Kumar Nayak maknayak@in.ibm.com>
5  * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
6  */
7 
8 /*\
9  * [Description]
10  *
11  * Test if waitid() filters children killed with SIGSTOP.
12  */
13 
14 #include <sys/wait.h>
15 #include "tst_test.h"
16 
17 static siginfo_t *infop;
18 
run(void)19 static void run(void)
20 {
21 	pid_t pid_child;
22 
23 	pid_child = SAFE_FORK();
24 	if (!pid_child) {
25 		SAFE_KILL(getpid(), SIGSTOP);
26 		TST_CHECKPOINT_WAIT(0);
27 		return;
28 	}
29 
30 	memset(infop, 0, sizeof(*infop));
31 	TST_EXP_PASS(waitid(P_PID, pid_child, infop, WSTOPPED | WNOWAIT));
32 
33 	TST_EXP_EQ_LI(infop->si_pid, pid_child);
34 	TST_EXP_EQ_LI(infop->si_status, SIGSTOP);
35 	TST_EXP_EQ_LI(infop->si_signo, SIGCHLD);
36 	TST_EXP_EQ_LI(infop->si_code, CLD_STOPPED);
37 
38 	SAFE_KILL(pid_child, SIGCONT);
39 
40 	TST_CHECKPOINT_WAKE(0);
41 }
42 
43 static struct tst_test test = {
44 	.test_all = run,
45 	.forks_child = 1,
46 	.needs_checkpoints = 1,
47 	.bufs = (struct tst_buffers[]) {
48 		{&infop, .size = sizeof(*infop)},
49 		{}
50 	}
51 };
52