Prevent pid 0 case 38/320938/3
authorChanggyu Choi <changyu.choi@samsung.com>
Tue, 26 Nov 2024 02:54:38 +0000 (11:54 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 26 Nov 2024 02:56:14 +0000 (11:56 +0900)
There is a case where the PID of app_status becomes zero due to some cause.
This patch contains defense against such cases.

Change-Id: If738d297af101d1ee6c3c646466b61f630592440
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/lib/app_status/app_status_manager.cc

index 124edc89b6ac75c7b94657b5540ebb8046f9ec4d..bd56f42f11413bd4f9b1067615fe5ebb5734d5e2 100644 (file)
@@ -166,6 +166,10 @@ void AppStatusManager::OnDyingTimeout(AppStatus* app_status) {
       app_status->GetAppID().c_str(), app_status->GetPID(),
       app_status->IsStarting() ? "true" : "false",
       app_status->GetDelayCount());
+
+  if (app_status->GetPID() <= 0)
+    return;
+
   int signo = SIGKILL;
   if (!app_status->IsStarting() && app_status->GetDelayCount() >= 10)
     signo = SIGABRT;
@@ -806,6 +810,11 @@ AppStatusPtr AppStatusManager::AddAppInfo(LaunchContext* context) {
   if (context == nullptr)
     return nullptr;
 
+  if (context->GetPid() <= 1) {
+    _E("Invalid pid(%d)", context->GetPid());
+    return nullptr;
+  }
+
   auto found = pid_map_.find(context->GetPid());
   if (found != pid_map_.end()) {
     auto& app_status = found->second;