Re: Fwd: fork and exec

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

 



Hi!

On 23:31 Sat 24 May     , Peter Teoh wrote:
> Sent on behalf of William Case:
> 
> From: William Case <billlinux@xxxxxxxxxx>
> Date: Sat, May 24, 2008 at 11:26 PM
> Subject: fork and exec

...

> My question is:  Why did the original designers of Multics/Unix choose
> to use the forking modal to start a new processes?  Do not other OSs use
> other modals?  What problem(s) did the fork overcome?  Couldn't a system
> have been designed that just (in some way) starts each process raw?
> Intuitively, copying a process then overwriting it seems wasteful or at
> least inelegant, so why is it needed?  How does a parent-to-child
> process enhance its (*nix's) design philosophy?
>
> Since forking is at the very core of the kernel, I would like to
> understand intellectually why the fork process is necessary?

Calling fork() does not mean that you want to start a program. If you have an
server, you can accept() a new conn and then call fork() to do the processing
in a new process. Actually fork is a wrapper for clone. You can create
processs which share address space, file system view, open file descriptors,
... whatever you like. Threads are also created this way.
 
If you searching for an "exec() which starts a command in a new process" you
can look at the system() call. If you want to read/write from/to stdout/stdin,
you can use popen. If you want to do both, have have to do a fork(), some
dup2() and an exec(). See
http://www.gnu.org/software/libc/manual/html_node/Processes.html#Processes
under "Running a Command"/"Pipe to a Subprocess".
	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


--
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