From: Christian Brauner Date: Tue, 2 Nov 2021 09:48:52 +0000 (+0100) Subject: start: log signal name and number X-Git-Tag: lxc-5.0.0~55^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0dec2ced0db347f5dd316cf5723e93f4e63b1a6;p=thirdparty%2Flxc.git start: log signal name and number Signed-off-by: Christian Brauner --- diff --git a/src/lxc/error.c b/src/lxc/error.c index a3467d517..05503ff83 100644 --- a/src/lxc/error.c +++ b/src/lxc/error.c @@ -8,6 +8,7 @@ #include "error.h" #include "log.h" +#include "process_utils.h" lxc_log_define(error, lxc); @@ -28,12 +29,12 @@ int lxc_error_set_and_log(int pid, int status) ret = WEXITSTATUS(status); if (ret) INFO("Child <%d> ended on error (%d)", pid, ret); - } - - if (WIFSIGNALED(status)) { - int signal = WTERMSIG(status); - INFO("Child <%d> ended on signal (%d)", pid, signal); - ret = 128 + signal; + } else if (WIFSIGNALED(status)) { + int signal_nr = WTERMSIG(status); + INFO("Child <%d> ended on signal %s(%d)", pid, signal_name(signal_nr), signal_nr); + ret = 128 + signal_nr; + } else { + ERROR("Invalid exit status (%d)", status); } return ret; diff --git a/src/lxc/start.c b/src/lxc/start.c index 1a6046c7a..d0a860361 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -2098,19 +2098,20 @@ int __lxc_start(struct lxc_handler *handler, struct lxc_operations *ops, * In any case, treat it as a 'halt'. */ if (WIFSIGNALED(status)) { - switch(WTERMSIG(status)) { + int signal_nr = WTERMSIG(status); + switch(signal_nr) { case SIGINT: /* halt */ - DEBUG("Container \"%s\" is halting", name); + DEBUG("%s(%d) - Container \"%s\" is halting", signal_name(signal_nr), signal_nr, name); break; case SIGHUP: /* reboot */ - DEBUG("Container \"%s\" is rebooting", name); + DEBUG("%s(%d) - Container \"%s\" is rebooting", signal_name(signal_nr), signal_nr, name); handler->conf->reboot = REBOOT_REQ; break; case SIGSYS: /* seccomp */ - DEBUG("Container \"%s\" violated its seccomp policy", name); + DEBUG("%s(%d) - Container \"%s\" violated its seccomp policy", signal_name(signal_nr), signal_nr, name); break; default: - DEBUG("Unknown exit status for container \"%s\" init %d", name, WTERMSIG(status)); + DEBUG("%s(%d) - Container \"%s\" init exited", signal_name(signal_nr), signal_nr, name); break; } }