2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 03:19:36 +00:00

start: log signal name and number

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner
2021-11-02 10:48:52 +01:00
parent ea0e384ff5
commit b0dec2ced0
2 changed files with 13 additions and 11 deletions

View File

@@ -8,6 +8,7 @@
#include "error.h" #include "error.h"
#include "log.h" #include "log.h"
#include "process_utils.h"
lxc_log_define(error, lxc); lxc_log_define(error, lxc);
@@ -28,12 +29,12 @@ int lxc_error_set_and_log(int pid, int status)
ret = WEXITSTATUS(status); ret = WEXITSTATUS(status);
if (ret) if (ret)
INFO("Child <%d> ended on error (%d)", pid, ret); INFO("Child <%d> ended on error (%d)", pid, ret);
} } else if (WIFSIGNALED(status)) {
int signal_nr = WTERMSIG(status);
if (WIFSIGNALED(status)) { INFO("Child <%d> ended on signal %s(%d)", pid, signal_name(signal_nr), signal_nr);
int signal = WTERMSIG(status); ret = 128 + signal_nr;
INFO("Child <%d> ended on signal (%d)", pid, signal); } else {
ret = 128 + signal; ERROR("Invalid exit status (%d)", status);
} }
return ret; return ret;

View File

@@ -2098,19 +2098,20 @@ int __lxc_start(struct lxc_handler *handler, struct lxc_operations *ops,
* In any case, treat it as a 'halt'. * In any case, treat it as a 'halt'.
*/ */
if (WIFSIGNALED(status)) { if (WIFSIGNALED(status)) {
switch(WTERMSIG(status)) { int signal_nr = WTERMSIG(status);
switch(signal_nr) {
case SIGINT: /* halt */ case SIGINT: /* halt */
DEBUG("Container \"%s\" is halting", name); DEBUG("%s(%d) - Container \"%s\" is halting", signal_name(signal_nr), signal_nr, name);
break; break;
case SIGHUP: /* reboot */ 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; handler->conf->reboot = REBOOT_REQ;
break; break;
case SIGSYS: /* seccomp */ 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; break;
default: 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; break;
} }
} }