xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/setpgrp/setpgrp02.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /*
4  * Copyright (c) International Business Machines  Corp., 2001
5  * 07/2001 Ported by Wayne Boyer
6  * Copyright (c) Linux Test Project, 2001-2016
7  * Copyright (C) 2024 SUSE LLC Andrea Manzini <[email protected]>
8  */
9 
10 /*\
11  * [Description]
12  *
13  * Testcase to check the basic functionality of the setpgrp(2) syscall.
14  */
15 
16 #include <unistd.h>
17 #include "tst_test.h"
18 
verify_setpgrp(void)19 static void verify_setpgrp(void)
20 {
21 	if (!SAFE_FORK()) {
22 		int oldpgrp = getpgrp();
23 
24 		TST_EXP_PASS(setpgrp());
25 		if (getpgrp() == oldpgrp)
26 			tst_res(TFAIL, "setpgrp() FAILED to set new group id");
27 		else
28 			tst_res(TPASS, "functionality is correct");
29 	}
30 }
31 
32 static struct tst_test test = {
33 	.test_all = verify_setpgrp,
34 	.forks_child = 1
35 };
36