Difference Between Fork And Exec


fork() is a system call used for creating a new process, which is known as the Child process. This child process runs concurrently along with the calling process which often referred to as the Parent process.

Negative Value: Unsuccessful child process creation.
Zero: Will be returned to the newly created child process.
Positive value: Will be returned to the parent or the caller process and the value will contain the process ID of the newly created child process.


The exec family of system calls always replaces the executed program with a process. At the point when a procedure calls exec, all codes (content) and information in the process are lost and exchanged with the executable of the new program.

Fork vs Exec:

  1. The fork system call generates a duplicate copy of the calling process, whereas; the exec system call is used to replace the entire current calling process with a new program altogether.
  2. The new process created by a fork system call is identical to the parent process in almost all respect, whereas; the new program which replaces the current process is loaded and is run from the entry point.
  3. After the fork system call, both the child and parent processes will be executed simultaneously, whereas; after the exec system call the control never get transferred to the original program until and unless an exec() error does not happen.
  4. Example:






Posted in Articles and tagged , , , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *