tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / test / clib / wait.c
blob54cf6e57519e362c661c5950bffd6522c1b8c81b
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <sys/wait.h>
9 #include <aros/debug.h>
10 #include "test.h"
12 #define EXIT_STATUS 123
14 int main()
16 char *argv0[] = { "Echo", "I'm child", NULL };
17 char *envp[] = { NULL };
18 pid_t pid;
19 pid_t wait_pid;
20 int status;
22 pid = vfork();
23 if((int) pid > 0)
25 printf("I'm parent, I have a child with pid %d\n", (int) pid);
26 printf("Waiting for child to exit.\n");
27 wait_pid = wait(&status);
28 TEST((wait_pid == pid));
29 printf("Child %d exited with exit status %d\n", (int) wait_pid, status);
30 TEST((status == EXIT_STATUS));
32 else if(pid == 0)
34 printf("Exiting with status %d\n", EXIT_STATUS);
35 _exit(EXIT_STATUS);
37 else
39 TEST(0);
42 pid = vfork();
43 if((int) pid > 0)
45 printf("I'm parent, I have a child with pid %d\n", (int) pid);
46 printf("Waiting for child to exit.\n");
47 wait_pid = wait(&status);
48 TEST((wait_pid == pid));
49 printf("Child %d exited with exit status %d\n", (int) wait_pid, status);
50 TEST((status == 0));
52 else if(pid == 0)
54 execve("C:Echo", argv0, envp);
55 _exit(EXIT_STATUS);
57 else
59 TEST(0);
61 return 0;
64 void cleanup()