corrections to scren bar rendering offsets
[AROS.git] / test / clib / vfork.c
blob24b96e4d1b2178cdb013b9ac666d283b8dd48e23
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <aros/debug.h>
4 #include <sys/wait.h>
5 #include "test.h"
7 int main()
9 pid_t pid;
10 int retval = RETURN_OK;
12 pid = vfork();
13 if((int) pid > 0)
15 int status = -1;
16 printf("I'm parent, I have a child with pid %d\n", (int) pid);
17 waitpid(pid, &status, 0);
18 if (status != 1)
19 return RETURN_FAIL;
21 else if(pid == 0)
23 printf("I'm child\n");
24 _exit(1);
26 else
28 TEST(0);
31 pid = vfork();
32 if((int) pid > 0)
34 printf("I'm parent, I have a first child with pid %d\n", (int) pid);
35 pid_t pid2 = vfork();
36 if((int) pid2 > 0)
38 int status = -1;
39 printf("I'm parent, I have a second child with pid %d\n", (int) pid2);
40 waitpid(pid2, &status, 0);
41 if (status != 2)
42 return RETURN_FAIL;
44 else if(pid2 == 0)
46 printf("I'm second child\n");
47 _exit(2);
49 waitpid(pid, NULL, 0);
51 else if(pid == 0)
53 pid_t pid2 = vfork();
54 int retval = 3;
55 if((int) pid2 > 0)
57 printf("I'm child, I have my child with pid2 %d\n", (int) pid2);
58 int status = -1;
59 waitpid(pid2, &status, 0);
60 if (status != 4)
61 retval = RETURN_FAIL;
63 else if(pid2 == 0)
65 printf("I'm the child of a child\n");
66 _exit(4);
68 _exit(retval);
70 else
72 TEST(0);
75 return retval;
78 void cleanup()