From cd64a45b9d1c125126ede61c1ff1a39b41ecaa24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Mon, 14 Apr 2025 14:03:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=89=93=E7=82=B9?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- bundle.json | 3 +-- hisysevent.yaml | 7 +++++++ modules/sysevent/event_reporter.cpp | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bundle.json b/bundle.json index 4801ab70..f97373fb 100644 --- a/bundle.json +++ b/bundle.json @@ -27,8 +27,7 @@ "rom": "296KB", "ram": "13125KB", "hisysevent_config": [ - "//base/startup/appspawn/hisysevent.yaml", - "//base/startup/appspawn/startup_events.yaml" + "//base/startup/appspawn/hisysevent.yaml" ], "deps": { "components": [ diff --git a/hisysevent.yaml b/hisysevent.yaml index 10df09ac..7c5e078e 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -13,6 +13,13 @@ domain: APPSPAWN +PROCESS_EXIT: + __BASE: {type: BEHAVIOR, level: CRITICAL, tag: Stability, desc: process exit reason} + PROCESS_NAME: {type: STRING, desc: process name} + PID: {type: UINT32, desc: process id} + UID: {type: UINT32, desc: user id} + STATUS: {type: INT32, desc: exit code or signal number} + SPAWN_CHILD_PROCESS_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: Spawn Child Process Fail} PROCESS_NAME: {type: STRING, desc: Process Name} diff --git a/modules/sysevent/event_reporter.cpp b/modules/sysevent/event_reporter.cpp index 687e7295..2bf0cb6b 100644 --- a/modules/sysevent/event_reporter.cpp +++ b/modules/sysevent/event_reporter.cpp @@ -36,8 +36,18 @@ void ProcessMgrRemoveApp(const char* processName, int pid, int uid, int status) pname = std::string(processName, strlen(processName)); } - HiSysEventWrite(HiSysEvent::Domain::STARTUP, KEY_PROCESS_EXIT, HiSysEvent::EventType::BEHAVIOR, - KEY_NAME, pname, KEY_PID, pid, KEY_UID, uid, KEY_STATUS, status); + int signal = 0; + if (WIFSIGNALED(status)) { + signal = WTERMSIG(status); + } + if (WIFEXITED(status)) { + signal = WEXITSTATUS(status); + } + + if (signal != 0) { + HiSysEventWrite(HiSysEvent::Domain::APPSPAWN, KEY_PROCESS_EXIT, HiSysEvent::EventType::BEHAVIOR, + KEY_NAME, pname, KEY_PID, pid, KEY_UID, uid, KEY_STATUS, status); + } } } // namespace system } // namespace OHOS -- Gitee