]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/error.c
github: Update for main branch
[mirror_lxc.git] / src / lxc / error.c
index 81d6a376e825942fddba4958dfb82faec7643c5c..05503ff83f49b0953b82ac2edc0c35cdf3d4e0f2 100644 (file)
@@ -1,25 +1,6 @@
-/*
- * lxc: linux Container library
- *
- * (C) Copyright IBM Corp. 2007, 2008
- *
- * Authors:
- * Daniel Lezcano <daniel.lezcano at free.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -27,8 +8,9 @@
 
 #include "error.h"
 #include "log.h"
+#include "process_utils.h"
 
-lxc_log_define(lxc_error, lxc);
+lxc_log_define(error, lxc);
 
 /*---------------------------------------------------------------------------*/
 /* lxc_error_set_and_log
@@ -39,7 +21,7 @@ lxc_log_define(lxc_error, lxc);
  *   128+n       signal n received by the application
  *   255         lxc error
  */
-extern int  lxc_error_set_and_log(int pid, int status)
+int lxc_error_set_and_log(int pid, int status)
 {
        int ret = 0;
 
@@ -47,11 +29,12 @@ extern 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);
+       } 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;