加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
util-virExec-may-blocked-by-reading-pipe-if-grandchi.patch 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
From 5122e578df1760c5e576682e3f84a1d18dbfca5d Mon Sep 17 00:00:00 2001
From: Xu Chao <xu.chao6@zte.com.cn>
Date: Wed, 24 Nov 2021 10:33:11 +0800
Subject: [PATCH 104/108] util: virExec may blocked by reading pipe if
grandchild prematurely exit
When VIR_EXEC_DAEMON is set, if virPidFileAcquirePath/virSetInherit failed,
then pipesync[0] can not be closed when granchild process exit, because
pipesync[1] still opened in child process. and then saferead in child
process may blocked forever, and left grandchild process in defunct state.
Signed-off-by: Xu Chao <xu.chao6@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 6fac961b085af51340246bf51205a9f2f1615962)
---
src/util/vircommand.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 8ab83cb8f5..bb824bf60f 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -775,6 +775,10 @@ virExec(virCommandPtr cmd)
}
if (pid > 0) {
+ /* At this point it's us and the child that holds the write end of
+ * the pipe open. Close the write end of the pipe, so that the pipe
+ * is fully closed if child dies prematurely. */
+ VIR_FORCE_CLOSE(pipesync[1]);
/* The parent expect us to have written the pid file before
* exiting. Wait here for the child to write it and signal us. */
if (cmd->pidfile &&
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化