nghttpx: Show textual signal description when worker process exited

This commit is contained in:
Tatsuhiro Tsujikawa 2015-09-22 21:21:40 +09:00
parent e77f9d95d3
commit 2be6a94d70
1 changed files with 17 additions and 2 deletions

View File

@ -370,11 +370,26 @@ void signal_cb(struct ev_loop *loop, ev_signal *w, int revents) {
namespace { namespace {
void worker_process_child_cb(struct ev_loop *loop, ev_child *w, int revents) { void worker_process_child_cb(struct ev_loop *loop, ev_child *w, int revents) {
std::string signalstr;
if (WIFSIGNALED(w->rstatus)) {
signalstr += ";signal ";
auto sig = WTERMSIG(w->rstatus);
auto s = strsignal(sig);
if (s) {
signalstr += s;
signalstr += "(";
} else {
signalstr += "UNKNOWN(";
}
signalstr += util::utos(sig);
signalstr += ")";
}
LOG(NOTICE) << "Worker process (" << w->rpid << ") exited " LOG(NOTICE) << "Worker process (" << w->rpid << ") exited "
<< (WIFEXITED(w->rstatus) ? "normally" : "abnormally") << (WIFEXITED(w->rstatus) ? "normally" : "abnormally")
<< " with status " << std::hex << w->rstatus << std::oct << " with status " << std::hex << w->rstatus << std::oct
<< "; exit status " << WEXITSTATUS(w->rstatus) << "; signal " << "; exit status " << WEXITSTATUS(w->rstatus)
<< (WIFSIGNALED(w->rstatus) ? WTERMSIG(w->rstatus) : 0); << (signalstr.empty() ? "" : signalstr.c_str());
ev_break(loop); ev_break(loop);
} }