[uClibc]Problem with vfork() followed by exec() on ARM7

Tonny Tzeng tzengym at ms8.hinet.net
Mon Sep 24 02:59:32 UTC 2001


Hi Erik,

I don't think it's the app's bug, neither fork.c in uClibc/test/unistd
nor your program below print the last message, but the old
uC-libc tree in cvs.uclinux.org works together with all these
sample programs. The following is the output of your code
on my Arm board:

> ls
bin
proc
sbin
dev
usr
>
> test
Hello.  I'm the parent process.
Hi.  I'm the child process...
bin
proc
sbin
dev
usr
> [sash is waiting for user command here]

BTW, I noticed you are using 2.4.9 kernel, do you think the
newest uClibc need to be run with 2.4 kernels?
Thanks for your help. :)

> Your app has several bugs in it.  Try this instead:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <sys/wait.h>
> int main(void)
> {
>     pid_t pid;
>     int status, wpid;
>     char *argv[] = {
>         "/bin/ls",
>         NULL,
>     };
>     if ((pid = vfork()) == 0) {
>         printf("Hi.  I'm the child process...\n");
>         execvp(argv[0], argv);
>         _exit(0);
>     }
>     printf("Hello.  I'm the parent process.\n");
>     while (1) {
>         wpid = wait(&status);
>         if (wpid > 0 && wpid != pid) {
>             continue;
>         }
>         if (wpid == pid)
>             break;
>     }
>     printf("Child process exited.\nGoodbye.\n");
>     return EXIT_SUCCESS;
> }
>
> Here it is running on my NetWinder:
>
>
> $ uname -a
> Linux winder 2.4.9-ac10-rmk1 #1 Wed Sep 19 22:30:24 MDT 2001 armv4l
unknown
> $
../../extra/gcc-uClibc/arm-uclibc-gcc -fomit-frame-pointer --uclibc-use-buil
d-dir -c vfork.c -o vfork.o
> $
../../extra/gcc-uClibc/arm-uclibc-gcc -s -Wl,-warn-common --uclibc-use-build
-dir vfork.o -o vfork
> $ strip -x -R .note -R .comment vfork
> $ ./vfork
> $ ../../ldso/util/ldd ./vfork
>         libc.so.0 => /usr/arm-linux-uclibc/lib/libc.so.0
>         /home/andersen/CVS/uClibc/lib/ld-uClibc.so.0 =>
/home/andersen/CVS/uClibc/lib/ld-uClibc.so.0
> $ ./vfork
> Hi.  I'm the child process...
> Hello.  I'm the parent process.
> CVS       fork    fork.o      fork_glibc.o  vfork.c  vfork_glibc
> Makefile  fork.c  fork_glibc  vfork         vfork.o  vfork_glibc.o
> Child process exited.
> Goodbye.
>
>
>  -Erik
>
> --
> Erik B. Andersen   email:  andersee at debian.org, formerly of Lineo
> --This message was written using 73% post-consumer electrons--







More information about the uClibc mailing list