Explain the different between the system function calls fork () and exec () ?
The fork() function is used to create a duplicate of the current process. When it duplicates the process, it creates a new process which almost identical, resource limit at some implementation, to the original process. The original process is known as parent process with associated PID and the newly created duplicate process is known as a child process with its own PID and it also holds the id of its parent process PPID.
The exec() function is used to replace the entire current process with a new one. It loads the new process in the memory space of current process and runs from the beginning.
For example, let's see a bash shell using ls command:-
Get Answers For Free
Most questions answered within 1 hours.