Modify SIGCHLD handler 41/296241/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 24 Jul 2023 07:01:57 +0000 (16:01 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 24 Jul 2023 07:01:57 +0000 (16:01 +0900)
If SIGCHLD signal is received, launchpad checks whether the pending request
exists or not. If it exists, launchpad sends the launch signal to listeners.

Change-Id: Ie82b4df2b49ce02beb95a4b7547584b6a674d424
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/dbus.cc
src/launchpad-process-pool/launchpad.cc

index 36b02b9..da24593 100644 (file)
@@ -165,7 +165,7 @@ class DBusManager {
       return;
     }
 
-    _D("[DBUS] %s", args->GetLogMessage().c_str());
+    _W("[DBUS] %s", args->GetLogMessage().c_str());
   }
 
   void WorkerThread() {
index 1891bf5..1ffb1ec 100644 (file)
@@ -598,6 +598,22 @@ void Launchpad::OnSigchldReceived(pid_t pid) {
     pid_map_.erase(found);
   }
 
+  auto iter = pending_requests_.begin();
+  while (iter != pending_requests_.end()) {
+    auto request = *iter;
+    auto context = request->GetAvailableLoaderContext();
+    if (context != nullptr && context->GetPid() == pid) {
+      context->Unref();
+      auto* app_info = request->GetAppInfo();
+      launchpad::DBus::SendAppLaunchSignal(context->GetPid(),
+        app_info->GetAppId().c_str());
+      pending_requests_.erase(iter);
+      break;
+    }
+
+    iter++;
+  }
+
   launchpad::Log::Print("[SIGCHLD]", "pid(%7d)", pid);
   LoaderManager::GetInst().HandleSigchld(pid);
 }