-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgetParentIDtest.c
39 lines (32 loc) · 1010 Bytes
/
getParentIDtest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# include "types.h"
# include "stat.h"
# include "user.h"
int main()
{
int p;
printf(1, "--------------Start Testing--------------\n");
printf(1, "This is process %d and the parent id is %d.\n", getpid(), getparentid());
p = fork();
if(p == 0)
{
printf(1, "----------------Step One----------------\n");
printf(1, "This is process %d and the parent id is %d.\n", getpid(), getparentid());
p = fork();
if(p == 0)
{
printf(1, "----------------Step two----------------\n");
printf(1, "This is process %d and the parent id is %d.\n", getpid(), getparentid());
p = fork();
if(p == 0)
{
printf(1, "---------------Step three---------------\n");
printf(1, "This is process %d and the parent id is %d.\n", getpid(), getparentid());
}
wait();
}
wait();
}
wait();
exit();
return 0;
}