Override exit code on process timeout

As Icinga first sends a SIGTERM to a check plugin on timeout to allow it to
terminate gracefully, this is not really part of the plugin API specification
and we cannot assume that plugins will handle this correctly and still exit
with an exit code that maps to UNKNOWN. Therefore, once Icinga decides to kill
a process, force its exit code to 128 to be sure the state will be UNKNOWN
after a timeout.
This commit is contained in:
Julian Brost 2021-07-27 09:26:38 +02:00
parent 9684fe8141
commit a55939e462
1 changed files with 8 additions and 2 deletions

View File

@ -1133,8 +1133,14 @@ bool Process::DoEvents()
} else if (WIFEXITED(status)) {
exitcode = WEXITSTATUS(status);
Log(LogNotice, "Process")
<< "PID " << m_PID << " (" << PrettyPrintArguments(m_Arguments) << ") terminated with exit code " << exitcode;
Log msg(LogNotice, "Process");
msg << "PID " << m_PID << " (" << PrettyPrintArguments(m_Arguments)
<< ") terminated with exit code " << exitcode;
if (m_SentSigterm) {
exitcode = 128;
msg << " after sending SIGTERM";
}
} else if (WIFSIGNALED(status)) {
int signum = WTERMSIG(status);
const char *zsigname = strsignal(signum);