c++waitexecl

waitpid getting hooked and not returning


I have a function that is calling a process called driverclear. Seems like the process starts but it never returns because I never get the output of the process and I never get the "Process Complete" message. Is there something I am doing wrong?

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

Solution

  • Instead of using execl I just switched to using system("sh root/helpers/driverclear"); which fixes my problems.