[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ash on MMU-less systems



On Fri, 26 Oct 2001, Stefan Soucek wrote:
> I am new to this list. I have one question about ash in the devboard-lx apps
> archive: Is this version supposed to work on MMU-less systems? It seems like
> it returns forkshell() after the vfork(); but the vfork man page says that
> you must not return from the function that called vfork(). Or am I
> overlooking an important thing here?

The important thing is that vfork in our elinux does not have standard
semantics (if there is such a thing anyway - vfork has traditionally meant
different things on different systems).

It forks while retaining the same memory but creates a new stack for the
new process. Then it sleeps the parent until the child has done exit or
exec. So it's perfectly ok to return from the parent function; it won't
happen until the child has released the parents memory and since the stack
is separate, any modifications the child does to the stack does not affect
the parent. However the child has to make sure no modifications are done
to the memory either which could adversely affect the parent.

There are numerous bad situations and exceptions that can happen, so the
only thing which is really safe to do is to vfork and immediately exec in
the child, with as little processing as possible in between (i.e. it's ok
to open a pipe and dup etc, but not to start reading/writing memory arrays
or complex things).

The moral is that if possible at all, try to use an MMU-full system :)

/BW