On Tue, 4 Jul 2006 15:27:17 +0800 "Edwin Eyan Moragas" <[EMAIL PROTECTED]> 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? > The child process gets an exact copy of the memory allocated by the parent process. A value available at a particular address in parent is available at the same address in child, except that it will be a copy and that modification in one of the processes won't affect the other. > 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? > If the parent process open()-s a file then fork()-s, the child will also get a copy of the file descriptor on which it can perform same operations as parent (read/write depending on open() flags).