[uClinux-dev] binfmt_flat.c and multiple processes with the same executable file

Greg Ungerer gerg at snapgear.com
Mon Oct 3 21:05:51 EDT 2005

Hi Avila,

Avila Mathieu wrote:
> Greg Ungerer wrote:
>> Avila Mathieu wrote:
>>> I am currently trying to run multiple processes from the same 
>>> executable file. It seems that in that case, i get always the same 
>>> TEXT/DATA/BSS segments.
>> Can you explain further, give your example?
>> What architecture are you working with?
> I am making a port of uClinux to the PowerPC (based on a 2.6.13 kernel), 
> specifically the 403GA in a NCD machine (explora401). However, it should 
> work for any other PowerPC.
> My intent is to give it back to the community when it is finished.
> Actually, i am able to boot, go through memory initialization, and run a 
> program; All relocations work fine, and my kernel is able to run a 
> Busybox shell, compiled together with uClibc.
> My troubles now are coming from vfork and mmapping.
> uClibc for PowerPC is using fork instead of vfork because :
>    /* Sigh.  The vfork system call on powerpc
>     * seems to be completely broken.  So just
>     * use fork instead */
> Do you have any idea for this ?

I don't know what the specific powerpc problem is with vfork.

> That should be the reason why it used to get the same mapping for the 
> same file (it didn't copy some pages/data, i think)

Yep, that was probably the real fork() at work.

> I have forced it to use vfork, and it seems ok.
> But when the 2nd process returns, unmmap crashes (nommu.c); it seems 
> some deallocations has already been done somewhere else. Or maybe it has 
> to be done in the arch-dependant code ? (i don't see things like this 
> for m68knommu)

No, I wouldn't expect anything like that in architecture specific code.
You may need to track the address given out at allocation time, and
trace all de-allocations to see where it might be going wrong.
For starters, does the munmap addresses match the addresses
alloation during the mmap in binfmt_flat?

> When i comment that code (exit_mmap), it runs ok (although it's not a 
> solution). However, i have read that after a vfork, the forking program 
> waits until the 2nd one makes a "exit" or  "execve". When it makes exit 
> directly, the 1st program gets back (ok), but it still blocks when the 
> 2nd program makes a execve, even if it returns. Do you have any idea ? 
> Do i have to change it's running state, or read its return code or 
> something like this ? Shouldn't it be done automatically by a signal 
> sent to the parent process ?

It should be automatic. I mean it is in common kernel code at least,
so I wouldn't expect you have to do anything special for the powerpc


Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg at snapgear.com
SnapGear -- a CyberGuard Company            PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

More information about the uClinux-dev mailing list