While the fork(2) system call starts a clone of the current process, the programmer is still left needing a way to start a new executable program. The exec(2) family of functions fills this need.
When a new program is executed, the following general steps are performed:
The kernel opens the new executable file for reading (and checks that the executable bit is set). An error is immediately returned to the caller if this fails.
The same process ID and addressable memory is retained, while the current execution becomes suspended.
The new program instructions are loaded from the executable file that has been opened by the kernel.
Certain process flags and registers are reset (for example the stack pointer is reset).
The execution ...