- Set a default PCM volume so that something can be heard when driver is
[AROS.git] / test / clib / wait.c
blobec840440cfcee03ac2b16daed797dd329b045659
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <sys/wait.h>
4 #include <aros/debug.h>
5 #include "test.h"
7 #define EXIT_STATUS 123
9 int main()
11 char *argv0[] = { "Echo", "I'm child", NULL };
12 char *envp[] = { NULL };
13 pid_t pid;
14 pid_t wait_pid;
15 int status;
17 pid = vfork();
18 if((int) pid > 0)
20 printf("I'm parent, I have a child with pid %d\n", (int) pid);
21 printf("Waiting for child to exit.\n");
22 wait_pid = wait(&status);
23 TEST((wait_pid == pid));
24 printf("Child %d exited with exit status %d\n", (int) wait_pid, status);
25 TEST((status == EXIT_STATUS));
27 else if(pid == 0)
29 printf("Exiting with status %d\n", EXIT_STATUS);
30 _exit(EXIT_STATUS);
32 else
34 TEST(0);
37 pid = vfork();
38 if((int) pid > 0)
40 printf("I'm parent, I have a child with pid %d\n", (int) pid);
41 printf("Waiting for child to exit.\n");
42 wait_pid = wait(&status);
43 TEST((wait_pid == pid));
44 printf("Child %d exited with exit status %d\n", (int) wait_pid, status);
45 TEST((status == 0));
47 else if(pid == 0)
49 execve("C:Echo", argv0, envp);
50 _exit(EXIT_STATUS);
52 else
54 TEST(0);
56 return 0;
59 void cleanup()