Re: vfork() from userland

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Mon, 1 Feb 1999 21:30:35 +0100 (CET)


> I have been been playing with the new vfork syscall... it seems that
> the child when embarking down the execve syscall road murders its parent.
> No doubt I will appear foolish before the world (Linus, may I borrow the
> brown paper bag please).
>
> My gut says the solution lies in protecting the parent's stack... but,
> I have yet to figure out the bloody thing.
>
> This bit of code behaves as is expected:
>
> #include "/usr/src/linux-2.2.1/include/asm/unistd.h"
> #include <stdio.h>
>
> int main (int argc, char **argv)
> {
> int i=0;
> if (!syscall(__NR_vfork)) {
> fprintf(stderr,"%d about to exec child\n",getpid(),++i);
> _exit(0);
> }
> fprintf(stderr,"%d parent %d\n",getpid(),i);
> }

This is wrong, you cannot do it like that. Look into glibc 2.0.112, it has
it right for most architectures (at least sparc, sparc64, ia32, maybe ARM,
AFAIK).

Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux | http://ultra.linux.cz/ | http://ultra.penguin.cz/
Linux version 2.2.1 on a sparc64 machine (3958.37 BogoMips)
___________________________________________________________________

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/