代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/etmem 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。