I’ve a problem with exec() function under ubuntu.
Is there any possibility to go back to the main program?
example:
printf("Some instructions at beginning\n");
execlp("ls","ls", "-l", NULL);
// i want to continue this program after exec and see the text below
printf("Other instructions\n");
No. A successful
execcall replaces the current program with another program. If you want both the parent and child to stick around, you need to callfork(2)beforeexec:Note that a failed
execcall (e.g. the given executable doesn’t exist) does return. Ifexecreturns, it’s always because of an error, so be prepared to handle the error.