Hello and welcome!
In this video session we will discuss the exec system call.
The exec system call is a function which is used to load a new program in the process memory.
So there arises some use cases in which the current program needs to be discarded, and the new program
needs to be loaded in the memory.
So this exact system call is used to perform such operations.
The process stack data and the heap are replaced by the new program, and the new program starts its
execution from the main function.
Let us see the syntax of the exec system call.
The exec system call takes three parameters the path name, the argv and the envp parameter.
So the exec system call on error, it returns a minus one, but upon success it does not return anything.
So let's see why it does not return anything.
And also for more reference on exec system call, we can see the manual pages of the exec.
Let's have a look into the manual pages of Execve.
So we can type mind space two space followed by the Z.
So here we can see the syntax as well.
It includes the file name the argv and the envp.
And we have to include the unistd.h.
Let's see the example to understand how this exactly works.
Also there is there is a set of library functions called as exec family function calls.
There are some variations of exec library functions which is implemented on top of the exec system call.
So exec is a system call.
And all this or library functions which are implemented on top of the exec v.
And these are also used to replace the existing program memory with a new program.
And similar to the exec v, these library functions returns a minus one on error, and in case of a
success, it does not return anything.
Let's see a few of the examples of this exec family library functions and exec system call in order
to understand how the exec works.