!462 fix lost return codes of spawned processe
Merge pull request !462 from zmr_2020/master
This commit is contained in:
commit
2d20e993c6
@ -0,0 +1,39 @@
|
||||
From 4ebca5a005afbc19c08f663e24d3e76518d12fa8 Mon Sep 17 00:00:00 2001
|
||||
From: Mohammed Ajmal Siddiqui <ajmalsiddiqui21@gmail.com>
|
||||
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 <ajmalsiddiqui21@gmail.com>
|
||||
---
|
||||
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
|
||||
|
||||
9
lxc.spec
9
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<zhang_jian7@hoperun.com> - 4.0.3-2022102418
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: fix lost return codes of spawned processe
|
||||
|
||||
* Fri Apr 21 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 4.0.3-2022102417
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user