if (fork() == 0) {
printf("Here comes the directory listing\n");
execlp("/bin/ls","ls",NULL);
printf("That is the end of the listing\n");
} else {
... /*----Some legal stuff here */
}
有人能告诉我这段代码有什么问题吗?
答案 0 :(得分:1)
调用execlp后,您的当前进程映像将被ls命令替换。你不会得到Printf输出。 execlp之后没有代码会运行
参考 - How do I printf() after a call to execlp() in a child process?