• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) International Business Machines  Corp., 2001
4  *
5  * Test case to check the basic functionality of kill() when killing an
6  * entire process group with a negative pid.
7  *
8  * HISTORY
9  *	07/2001 Ported by Wayne Boyer
10  */
11 
12 #include <sys/types.h>
13 #include <signal.h>
14 #include <sys/wait.h>
15 #include <unistd.h>
16 #include <stdlib.h>
17 #include "tst_test.h"
18 
verify_kill(void)19 static void verify_kill(void)
20 {
21 	int nsig, i, status;
22 
23 	if (!SAFE_FORK()) {
24 		setpgrp();
25 		for (i = 0; i < 5; i++) {
26 			if (!SAFE_FORK())
27 				pause();
28 		}
29 
30 		TEST(kill(-getpgrp(), SIGKILL));
31 		if (TST_RET != 0)
32 			tst_res(TFAIL | TTERRNO, "kill failed");
33 		exit(0);
34 	}
35 
36 	SAFE_WAITPID(-1, &status, 0);
37 	nsig = WTERMSIG(status);
38 	if (nsig != SIGKILL) {
39 		tst_brk(TFAIL, "wait: unexpected signal %d returned, "
40 			"expected SIGKILL(9)", nsig);
41 	}
42 
43 	tst_res(TPASS, "receive expected signal SIGKILL(9)");
44 }
45 
46 static struct tst_test test = {
47 	.forks_child = 1,
48 	.test_all = verify_kill,
49 };
50