diff --git a/bundle.json b/bundle.json index 8deb812fb4fe4db4a302cbec67b4bc67c7595c60..b43c8c64be30faec829f5315552b33631793ea72 100644 --- a/bundle.json +++ b/bundle.json @@ -33,8 +33,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 10df09ac4c3c8e1f24ba15ab58a54c1045032d8a..7c5e078e8a4b339a9dc68131b0a640337d3a3c8a 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 687e729581d506ce04f14e367fa69c469e1ce944..2bf0cb6ba1feb1fa2f69bbb1038101a8accc4715 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 diff --git a/startup_events.yaml b/startup_events.yaml deleted file mode 100644 index 4bf186289f4303624350b90cf128d98d3de4bdb0..0000000000000000000000000000000000000000 --- a/startup_events.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -domain: STARTUP - -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}