等待被迷住了,没有回来

waitpid getting hooked and not returning

本文关键字:回来 等待      更新时间:2023-10-16

我有一个函数调用一个名为driverclear的进程。似乎进程开始了,但它永远不会返回,因为我从未获得进程的输出,也从未收到"进程完成"消息。我做错了什么吗?

void cleanDriver
{
pid_t pid;
if(chmod("./helpers/driverclear", S_IXUSR) == 0)
{
int status = 0;
pid = fork();
if(pid == 0)
{
if(!execl("./helpers/driverclear", "driverclear", (char*) NULL))
{
perror("execl failed.n");
}
}
else
{
printf("Process Starting...");
waitpid(pid, &status, 0);
printf("Process Completen");
}
}
}

我没有使用execl而是改用system("sh root/helpers/driverclear");来解决我的问题。