conmon: check it is a valid PID before killing it
always check it is a valid PID before passing it down to kill(2).
Closes:
@@ -1434,9 +1434,11 @@ int main(int argc, char *argv[])
ret = waitpid(create_pid, &runtime_status, 0);
while (ret < 0 && errno == EINTR);
if (ret < 0) {
+ if (create_pid > 0) {
int old_errno = errno;
kill(create_pid, SIGKILL);
errno = old_errno;
+ }
pexitf("Failed to wait for `runtime %s`", opt_exec ? "exec" : "create");
}
}
@@ -1524,6 +1526,7 @@ int main(int argc, char *argv[])
const char *exit_message = NULL;
if (timed_out) {
+ if (container_pid > 0)
kill(container_pid, SIGKILL);
exit_message = "command timed out";
} else {
