如何让execlp()像系统一样工作(“睡5”)? 以下代码立即结束。
int main()
{
pid_t pid_child = fork();
int status;
if(pid_child == 0)
{
execlp("echo", "echo", "I will take a nap for a moment.", NULL);
execlp("sleep", "sleep", "5", NULL);
printf("Sleep has ended.\n");
}
else
{
wait(&status);
printf("Parent out.");
}
return 0;
}