1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * Copyright (c) Linux Test Project, 2006-2023
5 */
6
7 /*\
8 * [Description]
9 *
10 * Test whether parent process id that getppid() returns is out of range.
11 */
12
13 #include <errno.h>
14 #include "tst_test.h"
15
16 static pid_t pid_max;
17
setup(void)18 static void setup(void)
19 {
20 SAFE_FILE_SCANF("/proc/sys/kernel/pid_max", "%d\n", &pid_max);
21 }
22
verify_getppid(void)23 static void verify_getppid(void)
24 {
25 pid_t ppid;
26
27 ppid = getppid();
28 if (ppid > pid_max)
29 tst_res(TFAIL, "getppid() returned %d, out of range!", ppid);
30 else
31 tst_res(TPASS, "getppid() returned %d", ppid);
32 }
33
34 static struct tst_test test = {
35 .setup = setup,
36 .test_all = verify_getppid,
37 };
38