代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/libcareplus 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From b6b35d80755caed0528dfdf3825ecf055fe9ea76 Mon Sep 17 00:00:00 2001
From: Roman Rashchupkin <rrashchupkin@cloudlinux.com>
Date: Wed, 28 Feb 2018 23:05:50 +0300
Subject: [PATCH 16/89] Waitpid for finished threads after detach.
---
src/kpatch_process.c | 14 +++++++++++++-
src/kpatch_ptrace.c | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/kpatch_process.c b/src/kpatch_process.c
index 2f85373..5c0374a 100644
--- a/src/kpatch_process.c
+++ b/src/kpatch_process.c
@@ -12,6 +12,11 @@
#include <sys/stat.h>
#include <sys/sysmacros.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/ptrace.h>
+
#include <gelf.h>
#include <libunwind.h>
#include <libunwind-ptrace.h>
@@ -537,6 +542,8 @@ static void
process_detach(kpatch_process_t *proc)
{
struct kpatch_ptrace_ctx *p, *ptmp;
+ int status;
+ pid_t pid;
if (proc->memfd >= 0 && close(proc->memfd) < 0)
kplogerror("can't close memfd");
@@ -546,9 +553,14 @@ process_detach(kpatch_process_t *proc)
unw_destroy_addr_space(proc->ptrace.unwd);
list_for_each_entry_safe(p, ptmp, &proc->ptrace.pctxs, list) {
- kpatch_ptrace_detach(p);
+ if (kpatch_ptrace_detach(p) == -ESRCH) {
+ do {
+ pid = waitpid(p->pid, &status, __WALL);
+ } while (pid > 0 && !WIFEXITED(status));
+ }
kpatch_ptrace_ctx_destroy(p);
}
+ kpinfo("Finished ptrace detaching.");
}
static int
diff --git a/src/kpatch_ptrace.c b/src/kpatch_ptrace.c
index f91b80e..a5f61b3 100644
--- a/src/kpatch_ptrace.c
+++ b/src/kpatch_ptrace.c
@@ -1186,7 +1186,7 @@ int kpatch_ptrace_detach(struct kpatch_ptrace_ctx *pctx)
ret = ptrace(PTRACE_DETACH, pctx->pid, NULL, NULL);
if (ret < 0) {
kplogerror("can't detach from %d\n", pctx->pid);
- return -1;
+ return -errno;
}
kpdebug("OK\n");
--
2.23.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。