This preview shows page 1. Sign up to view the full content.
Unformatted text preview: to child, PID of child to parent, -1 on error The newly created child process is almost, but not quite, identical to the parent. The child gets an identical (but separate) copy of the parent’s user-level virtual address space, including the text, data, and bss segments, heap, and user stack. The child also gets identical copies of any of the parent’s open ﬁle descriptors, which means the child can read and write any ﬁles that were open in the parent when it called fork. The most signiﬁcant difference between the parent and the newly created child is that they have different PIDs. The fork function is interesting (and often confusing) because it is called once but it returns twice: once in the calling process (the parent), and once in the newly created child process. In the parent, fork returns the PID of the child. In the child, fork returns a value of 0. Since the PID of the child is always nonzero, the return value provides an unambiguous way to tell whether the program is executing in...
View Full Document
- Spring '10
- The American