Re: What is the practical significance of fork

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

 



On Wed, Dec 15, 2010 at 1:50 PM, Enrico Granata <egranata@xxxxxxxx> wrote:
> I believe his question actually sounds like: why does Linux need two system
> calls to start running a new program? Wouldn't it be simpler to do this the
> way Win32 does it: a CreateProcess() system call that actually loads a NEW
> program in  NEW process?

fork() and exec() are not going to be replaced in our lifetime, so you
are not going to be able to replace these system calls.  Rather, you
would be adding an extra system call which would cause all code using
the system call to break backwards compatibly with any kernels which
do not include this system call and break posix(not that that has
stopped Linux in the past).

This new system call would duplicate a lot of what fork is already doing.

Here is a list from the posix spec on exec[1] which specifies all the
elements inherited from the calling process and most of this is set up
by fork so therefore it would need to be duplicated in the new system
call.

"The new process shall inherit at least the following attributes from
the calling process image:

[XSI]  Nice value (see nice())

[XSI]  semadj values (see semop())

Process ID

Parent process ID

Process group ID

Session membership

Real user ID

Real group ID

Supplementary group IDs

Time left until an alarm clock signal (see alarm())

Current working directory

Root directory

File mode creation mask (see umask())

[XSI]  File size limit (see ulimit())

Process signal mask (see sigprocmask())

Pending signal (see sigpending())

tms_utime, tms_stime, tms_cutime, and tms_cstime (see times())

[XSI]  Resource limits

[XSI]  Controlling terminal

[XSI]  Interval timers"


I believe most would say overhead is minimized via COW and therefore
the speed benefit is not worth the issues as stated above.  I believe
that if the difference between fork/exec over one system call became
large enough  one may see a new system call created, but I do not see
that being accepted upsteam any time soon(not that I have any say).
fork/exec is a  proven and well understood method for most programmers
with c programming experience and while it may seem obscure at first
it really isn't that confusing.

Just my two cents,
John

[1]http://pubs.opengroup.org/onlinepubs/009695399/functions/environ.html

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux