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

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -