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