Computer: What is fork?
The child process, which begins its life as a copy of the parent process, can be "replaced".
In UNIX, the first program that is executed after booting finishes is the init process. This process will fork() and load the getty program over the child process, thereby creating a process which will prompt the user for a password.
Since a call to fork() creates a child process which is in essence the same as the parent process, it is necesarry to determine (from within the process) which process is the child, and which is the parent.
Upon sucesfull execution, the fork() call returns the child's Process ID in the parent process, and a 0 in the child proce ...more