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