Kill(pid, 0) seems to not set the error code correctly...as stated in man for kill
Errors
The kill() function shall fail if:
EINVAL The value of the sig argument is an invalid or unsupported signal number.
EPERM The process does not have permission to send the signal to any receiving process.
ESRCH No process or process group can be found corresponding to that specified by pid. The following sections are informative. 1
It is returning ENOENT (no such file or directory) and then sometimes it returns EINTR (system call interrupted)...
Here is what I am doing:
kill(g_StatusInstance[i].pid, SIGTERM) == -1 && log_fatal_syscall("kill-sigterm");
kill(g_StatusInstance[i].pid, 0);
log_info_console( "Checking process for errors: %s\n", strerror(errno));
if(errno != ENOENT)
{
kill(g_StatusInstance[i].pid, SIGKILL) == -1 && log_fatal_syscall("kill-sigkill");
}
Am I doing something wrong?