]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
start: log signal name and number
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Nov 2021 09:48:52 +0000 (10:48 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Nov 2021 10:14:58 +0000 (11:14 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/error.c
src/lxc/start.c

index a3467d5179862160200d24b1205f51d92becad8d..05503ff83f49b0953b82ac2edc0c35cdf3d4e0f2 100644 (file)
@@ -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;
index 1a6046c7a40d8b4bb3aebcf521545b3fce7db355..d0a860361a1d8a1cee0541070177b859d2702031 100644 (file)
@@ -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;
                }
        }