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
Post a Comment