compiler/clib: Remove usage of acb_environptr field outside __arosc_environ.c
[AROS.git] / test / clib / vfork_execl.c
blob38802c8503da96d8b8fe7a06424ab2f9633e4e41
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;
11 pid = vfork();
12 if((int) pid > 0)
14 printf("I'm parent, I have a child with pid %d\n", (int) pid);
15 waitpid(pid, NULL, 0);
17 else if(pid == 0)
19 execl("C:Echo", "Echo", "I'm child", NULL);
20 _exit(1);
22 else
24 TEST(0);
27 pid = vfork();
28 if((int) pid > 0)
30 printf("I'm parent, I have a first child with pid %d\n", (int) pid);
31 pid_t pid2 = vfork();
32 if((int) pid2 > 0)
34 printf("I'm parent, I have a second child with pid %d\n", (int) pid2);
35 waitpid(pid2, NULL, 0);
37 else if(pid2 == 0)
39 execl("C:Echo", "Echo", "I'm the second child of a parent", NULL);
40 _exit(1);
42 waitpid(pid, NULL, 0);
44 else if(pid == 0)
46 //printf("I'm child of a parent\n");
47 pid_t pid2 = vfork();
48 if((int) pid2 > 0)
50 //printf("I'm child, I have my child with pid %d\n", (int) pid2);
51 waitpid(pid2, NULL, 0);
53 else if(pid2 == 0)
55 execl("C:Echo", "Echo", "I'm child of a child", NULL);
56 _exit(1);
58 _exit(0);
60 else
62 TEST(0);
65 return OK;
68 void cleanup()