c - Why doesn't the last line of the child process print? -


#include <stdlib.h> #include <sys/wait.h> #include <unistd.h> #include <stdio.h>   int main( ) {     pid_t pid;     int status = -1;       if ((pid = fork()) != 0) {        printf("father process wait child pid=%d\n", pid);        wait(&status);        printf("child finish status: %d\n",wexitstatus(status));        exit(0);     }     else {        printf("child process running...\n");        execl("/bin/ls","ls", "-la", null);        printf("child ending...\n");     } } 

when compiling code last line of else doesn't print , don't know why.

http://linux.die.net/man/3/execl

the exec() family of functions replaces current process image new process image. ....

return value

the exec() functions return if error has occurred. return value -1, , errno set indicate error.


Comments

Popular posts from this blog

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -