From 018ecd52b07204b148fbfacf16b451da4d6315ff Mon Sep 17 00:00:00 2001 From: zmr_2020 Date: Thu, 4 May 2023 11:21:42 +0800 Subject: [PATCH] fix lost return codes of spawned processe (cherry picked from commit 4299137267b0a6452eccd8b547892f5960e3353c) --- ...ost-return-codes-of-spawned-processe.patch | 39 +++++++++++++++++++ lxc.spec | 9 ++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 0031-lxc-attach-Fix-lost-return-codes-of-spawned-processe.patch diff --git a/0031-lxc-attach-Fix-lost-return-codes-of-spawned-processe.patch b/0031-lxc-attach-Fix-lost-return-codes-of-spawned-processe.patch new file mode 100644 index 0000000..cef5a25 --- /dev/null +++ b/0031-lxc-attach-Fix-lost-return-codes-of-spawned-processe.patch @@ -0,0 +1,39 @@ +From 4ebca5a005afbc19c08f663e24d3e76518d12fa8 Mon Sep 17 00:00:00 2001 +From: Mohammed Ajmal Siddiqui +Date: Wed, 5 Oct 2022 12:20:58 +0530 +Subject: [PATCH] lxc-attach: Fix lost return codes of spawned processes that + are killed + +lxc-attach swallows the return codes of processes that are terminated +via a signal, and by default exits with a return code of 0 (i.e. +indicating success) even if the command it tried to execute was +terminated. + +This patch fixes it by explicitly checking if the process was terminated +via a signal, and returning an appropriate exit code. + +Note that we add 128 to the signal value to generate the exit code +because by convention the exit code is 128 + signal number. e.g. if a +process is killed via signal 9, then the error code is 9 + 128 = 137. + +Signed-off-by: Mohammed Ajmal Siddiqui +--- + src/lxc/tools/lxc_attach.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c +index fa303c7b4..6482b0aee 100644 +--- a/src/lxc/tools/lxc_attach.c ++++ b/src/lxc/tools/lxc_attach.c +@@ -399,6 +399,8 @@ int lxc_attach_main(int argc, char *argv[]) + } + if (WIFEXITED(ret)) + wexit = WEXITSTATUS(ret); ++ else if (WIFSIGNALED(ret)) ++ wexit = WTERMSIG(ret) + 128; + + out: + lxc_container_put(c); +-- +2.33.0 + diff --git a/lxc.spec b/lxc.spec index e54218b..0257a54 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 2022102417 +%global _release 2022102418 Name: lxc Version: 4.0.3 @@ -38,6 +38,7 @@ Patch0027: 0027-add-loongarch64-support-for-lxc.patch Patch0028: 0028-use-ocihooks-env-after-getenv.patch Patch0029: 0029-fix-mixed-use-of-signed-and-unsigned-type.patch Patch0030: 0030-remove-unused-meminfo-stats.patch +Patch0031: 0031-lxc-attach-Fix-lost-return-codes-of-spawned-processe.patch BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: pkgconfig(libseccomp) @@ -224,6 +225,12 @@ rm -rf %{buildroot}%{_sysconfdir}/default/%{name} %endif %changelog +* Thu May 04 2023 Jian Zhang - 4.0.3-2022102418 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: fix lost return codes of spawned processe + * Fri Apr 21 2023 zhangxiaoyu - 4.0.3-2022102417 - Type:bugfix - ID:NA -- Gitee