>huy vu wrote:
>> Thank to you both, Nacho and Joerg. However I would love to hear why
>> the call to exec would fail right after a call to fork(). From
>> reading things about vfork() it sounds like its sole purpose is to
>> allow people to call exec right after a fork. I just like to
>> understand why exec doesn't work well with fork(). Is it because the
>> scheduler is not ready or unpredictable after a fork()?

It's the call to fork() which will fail because of insufficient memory.

The call to exec is unlikely to fail except in the rare case of 
executables with huge data segments.

>Think of a situation where the memory footprint of the parent is large 
>and you want execute something with a small footprint, eg execing 
>something from a java process.
>
>The fact that you are execing means you don't need to access the address 
>space of the parent for communication so why copy it? (like is done in fork)
>
>Linux uses Copy on Write to address this problem.

All Unixes use COW for fork(); what Linux does differently is that it
does not reserve swap space so fork() does not claim any additional
swap resources.  (This is a tunable option)

In the case of an immediate exec, that is fine; in the case of fork()ed
child running it may lead to death of either process when a COW fault
is not able to allocate more swap.

Casper
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to