Modify thread control
[platform/core/appfw/launchpad.git] / src / lib / launchpad / thread_control.cc
index 62f6f26..680b305 100644 (file)
@@ -71,7 +71,7 @@ int GetThreadCountWithoutGmain(const std::vector<pid_t>& tasks) {
       // To avoid delay issue of calling usleep(), this function decreases
       // the count if the gmain threads exists.
       if (GetThreadName(tid) == "gmain") {
-        _W("%d is gmain thread", tid);
+        _D("%d is gmain thread", tid);
         count--;
       }
     }
@@ -177,9 +177,12 @@ void ThreadControl::SignalHandler(int signo) {
   auto& inst = ThreadControl::GetInst();
   std::unique_lock<std::mutex> lock(inst.mutex_);
   inst.count_--;
-  inst.cond_.wait(lock, [&] { return inst.done_; });
+  if (inst.cond_.wait_for(lock, std::chrono::seconds(5),
+                          [&] { return inst.done_; }))
+    _D("Unblock");
+  else
+    _E("Timed out");
   inst.count_--;
-  _D("Unblock");
 }
 
 }  // namespace launchpad