On Tuesday 30 May 2006 09:33, Ashok Sharma wrote: > Here is a related question. > When I fork() from a process a parent process with > some id is created together with a child process with > pid same a id of parent and id (of child) is zero. No. fork() only create the child process. > Now if from a child I fork() again then what will be > the pid and id of the child (or grand child) now. Both > cannot be zero again and what happens if I fork again > from the grand child? I am assuming by 'id' you mean the return value from fork(). The caller of fork() is always the parent and fork() returns twice. For the parent it returns the PID of the newly created child and for the child it returns 0. If this child process then calls fork again, it will now be the parent and you are back to the beginning of this paragraph. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/