[BusyBox] fork / vfork in init.c

Poul Erik Hansen peh at ellab.com
Tue Oct 26 05:58:05 UTC 2004


I think that would be the best solution.
Who has write access to the CVS to make this modification ?
Poul-Erik

-----Original Message-----
From: Rob Landley [mailto:rob at landley.net]
Sent: 22. oktober 2004 23:11
To: David Meggy; Poul Erik Hansen
Cc: busybox at mail.codepoet.org
Subject: Re: [BusyBox] fork / vfork in init.c


On Friday 22 October 2004 11:03, David Meggy wrote:
> On Fri, 2004-10-22 at 02:57, Poul Erik Hansen wrote:
> > Please add this patch
> >
> > @@ -52,6 +52,9 @@
> >  # include <sys/syslog.h>
> >  #endif
> >
> > +#if defined(__UCLIBC__) && !defined(__ARCH_HAS_MMU__)
> > +#define fork  vfork
> > +#endif
> >
> >  #define INIT_BUFFS_SIZE 256
>
> AHHH!!!!
>
> you can't do that.  If an application needs fork and there is no mmu,
> you are out of luck.  vfork can only be used if the child is able to
> share an address space with the parent (ie it never returns from the
> function that called it).  Please read the man page on vfork.
>
> If you want to port an application to an mmuless processor then you will
> have to search for every fork call and examine it individually, and
> possibly modify the code to make it vfork safe.  Then change that fork
> to vfork.
>
> David

Init used to be using vfork (up until recently), which is needed on certain 
mutant mmu-less systems that can't fork properly.  It seems to have been 
taken out recently (to fix a bug caused by inappropriate use of vfork on 
systems that DO have an MMU), and the above patch is trying to put it back.

The fork calls that _init_ makes have, indeed, been tested to work with vfork, 
in certain cases.  But only in certain cases, and it's icky to use vfork on a 
system that has a working fork anyway.  Even some mmu-less systems seem to 
have a working fork, so the above #ifdef is insufficient.

Probably the cleanest way to deal with it is a config option: "init uses 
vfork", that defaults to N.

Rob



More information about the busybox mailing list