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