In: Computer Science
What is the fork() function? Why is it important? What is it used for? What does the child inherit?
fork() function: It is used to create new process by duplicating the existing process from which it is called and that process is child process of caller.After a new child process is created,both processes will execute the next instructions following the fork() function.This function takes no argument and return process ID.
Fork() function creates the 2^n processes.
It is used for creating the child processes.
The child process has a unique process ID, which also does not match any active process group ID.
The child process has a different parent process ID (that is, the process ID of the process that called fork()).
The child process has its own copy of the parent's file descriptors Each of the child's file descriptors refers to the same open file structures as the file descriptor of the parent.
The child process has its own copy of the parent's open directory streams