From d93a8a408f36cced1d9cf863e3915755d386ba61 Mon Sep 17 00:00:00 2001 From: GeronHW Date: Sat, 4 Nov 2023 02:12:12 +0000 Subject: [PATCH] fault_logger_daemon: Specify the main thread as the target thread of signal Signed-off-by: GeronHW <910971217@qq.com> --- services/fault_logger_daemon.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/services/fault_logger_daemon.cpp b/services/fault_logger_daemon.cpp index 57f1262b9..368d154a2 100644 --- a/services/fault_logger_daemon.cpp +++ b/services/fault_logger_daemon.cpp @@ -419,20 +419,24 @@ void FaultLoggerDaemon::HandleSdkDumpRequest(int32_t connectionFd, FaultLoggerdR .si_uid = static_cast(request->callerTid) }; #pragma clang diagnostic pop - // means we need dump all the threads in a process. + int32_t reqTid = 0; if (request->tid == 0) { - if (syscall(SYS_rt_sigqueueinfo, request->pid, si.si_signo, &si) != 0) { - DFXLOG_ERROR("Failed to SYS_rt_sigqueueinfo signal(%d), errno(%d).", si.si_signo, errno); - resSdkDump = FaultLoggerSdkDumpResp::SDK_DUMP_NOPROC; - break; - } + /* + * means we need dump all the threads in a process + * -------- + * Accroding to the linux manual, A process-directed signal may be delivered to any one of the + * threads that does not currently have the signal blocked. So we should specify the main thread + * as the target thread of signal. + */ + reqTid = request->pid; } else { // means we need dump a specified thread - if (syscall(SYS_rt_tgsigqueueinfo, request->pid, request->tid, si.si_signo, &si) != 0) { - DFXLOG_ERROR("Failed to SYS_rt_tgsigqueueinfo signal(%d), errno(%d).", si.si_signo, errno); - resSdkDump = FaultLoggerSdkDumpResp::SDK_DUMP_NOPROC; - break; - } + reqTid = request->tid; + } + if (syscall(SYS_rt_tgsigqueueinfo, request->pid, reqTid, si.si_signo, &si) != 0) { + DFXLOG_ERROR("Failed to SYS_rt_tgsigqueueinfo signal(%d), errno(%d).", si.si_signo, errno); + resSdkDump = FaultLoggerSdkDumpResp::SDK_DUMP_NOPROC; + break; } } while (false); -- Gitee