--- Denis Vlasenko <[EMAIL PROTECTED]> wrote:
> On 8/2/07, Alex Landau <[EMAIL PROTECTED]> wrote:
> > --- Mike Frysinger <[EMAIL PROTECTED]> wrote:
> >
> > > On Thursday 02 August 2007, Alex Landau wrote:
> > > > + if (pid != 0) /* parent */
> > > > + exit(0); /* the child may have changed the
> > > > stack,
> > > > so no return possible, only function calls */ /* child */
> > >
> > > i havent read the code, but gut feeling says that should be _exit(0) ...
> > > or do
> > > i need to read the code ? :)
> > > -mike
>
> Thanks for testing Alex, I am applying the patch.
> I am also reusing write_pidfile() from libbb here:
>
> if (opt & OPT_MAKEPID) {
> /* user wants _us_ to make the pidfile */
> write_pidfile(pidfile);
> }
>
> In the process I (hopefully) fixed that nasty
> "ifupdown + udhcpc_without_pidpile_creation" fsckup...
>
Tested, working.
> > You do need to read the code :-)
> > It's the parent who runs exit(), not the child, so it should be exit() and
> > not
> _exit().
>
> Mike is implying that _exit() is mucking around much less that exit()
> and for paranoid
> reasons we are better off using it. So I changed exit to _exit in that spot.
> We don't even need to fflush() before that, we did no output yet.
I'm still not sure _exit is better in this case, but I'm not 100% sure it's
wrong too...
Anyway it's currently working.
>
> > The child merely execv()s.
>
> So on NOMMU execv() basically creates another process in another
> memory region, and
> terminates current one, unless there is a parent sitting in vfork and waiting
> (in which case parent is woken up instead of exit)?
No, execve works exactly it does on an MMU system. It loads a new executable
into the
current process. The difference is with vfork: on vfork, the parent is
suspended, and the
child shares it's whole address space with the parent (the stack is shared too
- that's
why this is so tricky!). The parent is resumed when the child either execve()s
or
_exit()s.
> --
> vda
>
Alex
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the
tools to get online.
http://smallbusiness.yahoo.com/webhosting
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox