1 Star 0 Fork 44

firstadream/lxc

forked from src-openEuler/lxc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0031-lxc-attach-Fix-lost-return-codes-of-spawned-processe.patch 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
From 4ebca5a005afbc19c08f663e24d3e76518d12fa8 Mon Sep 17 00:00:00 2001
From: Mohammed Ajmal Siddiqui <[email protected]>
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 <[email protected]>
---
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/firstadream/lxc.git
[email protected]:firstadream/lxc.git
firstadream
lxc
lxc
master

搜索帮助