cleanup composer/compositing/composition -> compositor
[AROS.git] / test / clib / vfork_execl.c
blob1fb506f8437d8bfae76bcef2bc255a16cc79698b
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 /* Test vfork and a child doing execl() */
12 pid = vfork();
13 if((int) pid > 0)
15 printf("I'm parent, I have a child with pid %d\n", (int) pid);
16 waitpid(pid, NULL, 0);
18 else if(pid == 0)
20 execl("C:Echo", "Echo", "I'm child", NULL);
21 _exit(1);
23 else
25 TEST(0);
27 printf("\n");
29 /* Testing child trying to exec non-existing program */
30 pid = vfork();
31 if((int) pid > 0)
33 printf("I'm parent, I have a child with pid %d\n", (int) pid);
34 waitpid(pid, NULL, 0);
36 else if(pid == 0)
38 TEST(execl(":XYZ/NotExist", "NotExist", "I'm child", NULL) == -1);
39 _exit(0);
41 else
43 TEST(0);
46 /* Testing nested vfork() + execl() */
47 pid = vfork();
48 if((int) pid > 0)
50 printf("I'm parent, I have a first child with pid %d\n", (int) pid);
51 pid_t pid2 = vfork();
52 if((int) pid2 > 0)
54 printf("I'm parent, I have a second child with pid %d\n", (int) pid2);
55 waitpid(pid2, NULL, 0);
57 else if(pid2 == 0)
59 execl("C:Echo", "Echo", "I'm the second child of a parent", NULL);
60 _exit(1);
62 waitpid(pid, NULL, 0);
64 else if(pid == 0)
66 //printf("I'm child of a parent\n");
67 pid_t pid2 = vfork();
68 if((int) pid2 > 0)
70 //printf("I'm child, I have my child with pid %d\n", (int) pid2);
71 waitpid(pid2, NULL, 0);
73 else if(pid2 == 0)
75 execl("C:Echo", "Echo", "I'm child of a child", NULL);
76 _exit(1);
78 _exit(0);
80 else
82 TEST(0);
85 return OK;
88 void cleanup()