OSDN Git Service

fix license notice
[uclinux-h8/uclibc-ng.git] / test / unistd / vfork.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * vfork test for uClibc
4  *
5  * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
6  * Written by Erik Andersen <andersen@uclibc.org>
7  *
8  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
9  */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <sys/wait.h>
15 #include <sys/types.h>
16
17
18 int main(void) 
19 {
20         pid_t pid;
21         int status, wpid;
22         char *argv[] = {
23                 "/bin/ls",
24                 "-laF",
25                 NULL,
26         };
27
28         clearenv();
29         if ((pid = vfork()) == 0) {
30                 printf("Hi.  I'm the child process...\n");
31                 execvp(argv[0], argv);
32                 _exit(0);
33         }
34
35         printf("Hello.  I'm the parent process.\n");
36         while (1) {
37                 wpid = wait(&status);
38                 if (wpid > 0 && wpid != pid) {
39                         continue;
40                 }
41                 if (wpid == pid)
42                         break;
43         }
44
45         printf("Child process exited.\nGoodbye.\n");
46         return EXIT_SUCCESS;
47 }
48
49 /*
50 Local Variables:
51 c-file-style: "linux"
52 c-basic-offset: 4
53 tab-width: 4
54 End:
55 */