On Tue, Jul 04, 2006 at 03:27:17PM +0800, Edwin Eyan Moragas wrote: > ey misc, > > from the fork(2) man pages: > > fork() causes creation of a new process. The new process (child process) > is an exact copy of the calling process (parent process) except for the > following: <snip> > > i have several questions/clarifications regarding this. > > 1) when it says "exact copy", does this mean just a copy of the process? > is it right to state that the memory allocated by the parent process is not > accessible to the child process?
Yes, copy is not the original (though normally Unix-OSs do a lazy copy-on-write after a fork). If you want shared memory between partent and child, have a look at shmat (2). > 2) "The child process has its own copy of the parent's descriptors." i take > this to mean all file and socket descriptors which both parent and child > can write and read to. am i correct? It means all file descriptors of the partent process at the time of the fork will be copied to the child process. As a result, there will be two processes able to write to the same file. You might have a look at pipe(2) to see the benefits of this. Bernd