1 Star 0 Fork 20

linfeilong835/etmem_src

forked from src-openEuler/etmem 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0004-etmem-fix-multiple-etmemd-and-too-many-err-log-probl.patch 2.42 KB
一键复制 编辑 原始数据 按行查看 历史
刘波 提交于 2023-06-08 14:31 . etmem: backport bugfix patch from upstream
From 5ca2bdd61980b8cf501bc9397611260f4745a7e6 Mon Sep 17 00:00:00 2001
From: liubo <[email protected]>
Date: Tue, 6 Jun 2023 21:14:35 +0800
Subject: [PATCH 4/4] etmem: fix multiple etmemd and too many err log problem
1. the etmem uses the fork and exec mode to run the
feature command to botain the corresponding process information.
If the cmd does not exist, the fork subprocess may not
exit, but the parent process is suspended.
As a result, new etmemd processes are continuously started.
Signed-off-by: liubo <[email protected]>
---
etmem/src/etmemd_src/etmemd_task.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/etmem/src/etmemd_src/etmemd_task.c b/etmem/src/etmemd_src/etmemd_task.c
index dfe911f..a50c78d 100644
--- a/etmem/src/etmemd_src/etmemd_task.c
+++ b/etmem/src/etmemd_src/etmemd_task.c
@@ -48,26 +48,33 @@ static int get_pid_through_pipe(char *arg_pid[], const int *pipefd)
if (stdout_copy_fd < 0) {
etmemd_log(ETMEMD_LOG_ERR, "dup(STDOUT_FILENO) fail.\n");
close(pipefd[1]);
- return -1;
+ exit(SIGPIPE);
}
ret = dup2(pipefd[1], fileno(stdout));
if (ret == -1) {
etmemd_log(ETMEMD_LOG_ERR, "dup2 pipefd fail.\n");
close(pipefd[1]);
- return -1;
+ exit(SIGPIPE);
+ }
+
+ ret = dup2(pipefd[1], fileno(stderr));
+ if (ret == -1) {
+ etmemd_log(ETMEMD_LOG_ERR, "dup2 piped fail.\n");
+ close(pipefd[1]);
+ exit(SIGPIPE);
}
if (execve(arg_pid[0], arg_pid, NULL) == -1) {
etmemd_log(ETMEMD_LOG_ERR, "execve %s fail with %s.\n", arg_pid[0], strerror(errno));
close(pipefd[1]);
- return -1;
+ exit(SIGPIPE);
}
- if (fflush(stdout) != 0) {
+ if (fflush(stdout) != 0 || fflush(stderr) != 0) {
etmemd_log(ETMEMD_LOG_ERR, "fflush execve stdout fail.\n");
close(pipefd[1]);
- return -1;
+ exit(SIGPIPE);
}
close(pipefd[1]);
dup2(stdout_copy_fd, fileno(stdout));
@@ -75,6 +82,10 @@ static int get_pid_through_pipe(char *arg_pid[], const int *pipefd)
/* wait for execve done */
wait(&status);
+ if ((WIFEXITED(status) && WEXITSTATUS(status) == SIGPIPE) ||
+ !WIFEXITED(status)) {
+ return -1;
+ }
return 0;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/volcanodragon/etmem_src.git
[email protected]:volcanodragon/etmem_src.git
volcanodragon
etmem_src
etmem_src
master

搜索帮助