So I know that anything that comes after exec*
functions will not get executed (if the exec* call is successful of course).
I want to understand why is this so ? So I developed this tiny little program
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
printf("A program made to understand execvp\n");
char *cmd[4] = {"ls", "-l","file",NULL};
execvp(cmd[0],cmd);
printf("This will not be printed!!\n");
return 0;
}
What I do understand is that executable commands like those found in the bin directory are actually executable programs and so when basically call another program from our program.
And I did read somewhere that
if successful, the exec system calls do not return to the invoking program as the calling image is lost.
But what does this really means, and why do they not return to the invoking program ? How do they return then ?