]> granicus.if.org Git - icinga2/commitdiff
Improve error messages for the Process class
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 13 Nov 2014 07:53:12 +0000 (08:53 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 13 Nov 2014 07:53:12 +0000 (08:53 +0100)
lib/base/process.cpp

index 065d40e2bc8d7df905261e2fbdce3fda3d80c555..fa6b04bf47afa75e668959d795f8cbc743e3e959 100644 (file)
@@ -674,11 +674,22 @@ bool Process::DoEvents(void)
                Log(LogNotice, "Process")
                    << "PID " << m_PID << " (" << PrettyPrintArguments(m_Arguments) << ") terminated with exit code " << exitcode;
        } else if (WIFSIGNALED(status)) {
+               int signum = WTERMSIG(status);
+               char *zsigname = strsignal(signum);
+
+               String signame = Convert::ToString(signum);
+
+               if (zsigname) {
+                       signame += " (";
+                       signame += zsigname;
+                       signame += ")";
+               }
+
                Log(LogWarning, "Process")
-                   << "PID " << m_PID << " was terminated by signal " << WTERMSIG(status);
+                   << "PID " << m_PID << " was terminated by signal " << signame;
 
                std::ostringstream outputbuf;
-               outputbuf << "<Terminated by signal " << WTERMSIG(status) << ".>";
+               outputbuf << "<Terminated by signal " << signame << ".>";
                output = output + outputbuf.str();
                exitcode = 128;
        } else {