waitpid 被钩住并且不返回

waitpid getting hooked and not returning

我有一个函数正在调用一个名为 driverclear 的进程。似乎该过程开始了,但它从来没有 returns 因为我从来没有得到过程的输出,我也从来没有得到 "Process Complete" 消息。我做错了什么吗?

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 Complete\n");
        }
    }
}

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