Linux WaitForSingleObject?

2020-05-02 08:45发布

Here a piece of code showing the problem

//main

Process* process = NULL;
while(!process) {
    cout<<endl<<"Waiting for second process.\nPress any key";
    getchar();
    getchar();

    process = Process::takeExisting("process");
}
Process::waitEnd(process); //Problem here
cout<<endl<<"second process ended";

//Process::waitEnd

static void waitEnd(Process* proc) {
        int w = waitpid(proc->hProcess, &(proc->exitCode), WCONTINUED);
        Debug::error(errno," waitpid error - ");
    }

I've tried: stop first, wait second ends, continue first.

The problem: the second process is not child( I run it from second console ) so with this code errno is equal to 10. How to solve this on Linux?

标签: c++ linux wait
0条回答
登录 后发表回答