From 0467ed114b501414645c2dd68fe11d461f31d69c Mon Sep 17 00:00:00 2001 From: xlgitee Date: Sat, 13 Sep 2025 18:26:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8fork=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=8E=89=E7=94=A8=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=8B=89=E8=B5=B7?= =?UTF-8?q?perf=20fork=E9=92=A9=E5=AD=90=E9=98=BB=E5=A1=9E=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xlgitee Change-Id: Iaf364f99fbf856f9839ae5ebf43d5b5df3730fcb --- interfaces/innerkits/dump_catcher/lite_perf.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/dump_catcher/lite_perf.cpp b/interfaces/innerkits/dump_catcher/lite_perf.cpp index e048bc198..611748a53 100644 --- a/interfaces/innerkits/dump_catcher/lite_perf.cpp +++ b/interfaces/innerkits/dump_catcher/lite_perf.cpp @@ -323,6 +323,15 @@ int LitePerf::Impl::WaitpidTimeout(pid_t pid) return -1; } +static pid_t ForkBySyscall(void) +{ +#ifdef SYS_fork + return syscall(SYS_fork); +#else + return syscall(SYS_clone, SIGCHLD, 0); +#endif +} + int LitePerf::Impl::ExecDump(const std::vector& tids, int freq, int durationMs) { static LitePerfParam lperf; @@ -330,8 +339,7 @@ int LitePerf::Impl::ExecDump(const std::vector& tids, int freq, int duratio return -1; } - pid_t pid = 0; - pid = fork(); + pid_t pid = ForkBySyscall(); if (pid < 0) { DFXLOGE("Failed to fork."); return -1; @@ -343,7 +351,7 @@ int LitePerf::Impl::ExecDump(const std::vector& tids, int freq, int duratio _exit(-1); } - pid_t dumpPid = fork(); + pid_t dumpPid = ForkBySyscall(); if (dumpPid < 0) { DFXLOGE("Failed to fork."); _exit(-1); -- Gitee