A fork creates a new process by duplicating the caller. The system call fork() makes a child whose memory is a copy of the parent’s, with the same open files and working directory, and both processes continue from the return of fork. It returns 0 in the child and the child’s PID in the parent, or in the parent, with no child, if it fails.
fork_basic.c. The two address spaces start equal, except for the value fork returned; the child’s assignment books = 20 does not reach the parent.fork_tree.c: an edge goes from a parent to a child. The fork of index is made by every process alive at that moment, and doubles their number.