How to check whether it is running a child process?

Need to run a process in the parent process to check whether it is started. I want to do it with a library of POCO like this:
poco::ProcessHandle handle = poco::Process::launch(path, arg, workingDirectory);
if ( !poco::Process::isRunning(handle) )
{
...
}

Everything inside works as follows: called fork() pid is stored. In the child process invokes execvp() , and next, it calls _exit();

Inside the isRunning() is called kill(pid, 0).

All of this works, the issue occurs when the path variable is zero, then there is no other executable file will be executed should not. But why kill(pid, 0) returns 0, i.e. the process is running, how can this be?

Maybe it will be clearer:
int main(int argc, char** argv)
{
 int pid = fork();
 if ( pid == 0)
{
 int pid = getpid();
 int ppid = getppid();

 printf("Child process: pid: %d \n", pid);
 printf("Child process: ppid: %d \n", ppid);
 int res = execvp("", NULL);
 printf("Child process: res: %d \n", res);
_exit(72);
}
sleep(3);

 if ( kill(pid, 0) == 0 )
{
 printf("kill returned 0 \n");
}

 return 0;
}


Conclusion:
Child process: pid: 3542 
Child process: ppid: 3533 
Child process: res: -1 
kill returned 0


The output of ps-ef | grep 3533

milai 3533 3531 0 15:55 pts/6 00:00:00 /home/milai/project/test/build/testApp
milai 3542 3533 0 15:55 pts/6 00:00:00 [testApp] <defunct>
milai 3561 2579 0 15:57 pts/4 00:00:00 grep --color=auto 3533</defunct>
June 14th 19 at 21:03
1 answer
June 14th 19 at 21:05
Solution
It looks like you got a zombie process. The parent process should read the return code using wait/waitpid.
https://ru.stackoverflow.com/a/484142/221454

Find more questions by tags C++Linux