xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/getpgid/getpgid02.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) International Business Machines  Corp., 2001
4  *   07/2001 Ported by Wayne Boyer
5  * Copyright (c) 2023 SUSE LLC Avinesh Kumar <[email protected]>
6  */
7 
8 /*\
9  * [Description]
10  *
11  * Verify that getpgid(2) fails with errno ESRCH when
12  * pid does not match any process.
13  */
14 
15 #include "tst_test.h"
16 
17 static pid_t unused_pid;
18 static pid_t neg_pid = -99;
19 
setup(void)20 static void setup(void)
21 {
22 	unused_pid = tst_get_unused_pid();
23 }
24 
run(void)25 static void run(void)
26 {
27 	TST_EXP_FAIL2(getpgid(neg_pid), ESRCH, "getpgid(%d)", neg_pid);
28 	TST_EXP_FAIL2(getpgid(unused_pid), ESRCH, "getpgid(%d)", unused_pid);
29 }
30 
31 static struct tst_test test = {
32 	.setup = setup,
33 	.test_all = run
34 };
35