1 Star 0 Fork 43

gaohuatao / lxc

forked from src-openEuler / lxc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0060-attach-append-error-msg-when-call-attach-failed.patch 1.42 KB
一键复制 编辑 原始数据 按行查看 历史
From de512a0c11bff1bfc8f0045e144bddc689742a21 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Thu, 30 Apr 2020 16:40:14 +0800
Subject: [PATCH] attach: append error msg when call attach failed
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
src/lxc/tools/lxc_attach.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c
index 190f3c8..dbddc2a 100644
--- a/src/lxc/tools/lxc_attach.c
+++ b/src/lxc/tools/lxc_attach.c
@@ -401,12 +401,17 @@ static int do_attach_foreground(struct lxc_container *c, lxc_attach_command_t *c
ret = c->attach(c, lxc_attach_run_command, command, attach_options, &pid);
else
ret = c->attach(c, lxc_attach_run_shell, NULL, attach_options, &pid);
- if (ret < 0)
+ if (ret < 0) {
+ *errmsg = safe_strdup("Internal error, failed to call attach");
goto out;
+ }
ret = lxc_wait_for_pid_status(pid);
- if (ret < 0)
+ if (ret < 0) {
+ free(*errmsg);
+ *errmsg = safe_strdup("Internal error, failed to wait attached process");
goto out;
+ }
if (WIFEXITED(ret))
wexit = WEXITSTATUS(ret);
@@ -421,8 +426,10 @@ static int do_attach_foreground(struct lxc_container *c, lxc_attach_command_t *c
ERROR("Execd pid %d exit with %d", pid, wexit);
out:
- if (c->lxc_conf->errmsg)
+ if (c->lxc_conf->errmsg) {
+ free(*errmsg);
*errmsg = safe_strdup(c->lxc_conf->errmsg);
+ }
return wexit;
}
--
1.8.3.1
1
https://gitee.com/gaohuatao/lxc.git
git@gitee.com:gaohuatao/lxc.git
gaohuatao
lxc
lxc
master

搜索帮助