launchpad: add instantiated and terminate methods 71/64071/2
authorJaemin Ryu <jm77.ryu@samsung.com>
Wed, 30 Mar 2016 01:01:50 +0000 (10:01 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Wed, 6 Apr 2016 06:06:39 +0000 (23:06 -0700)
Change-Id: I00b9bfd80648cb1463255d1fba38aa3f58a95939
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
server/launchpad.cpp
server/launchpad.h

index c89d7b5..20817c8 100644 (file)
@@ -16,6 +16,8 @@
 
 #include <sys/types.h>
 #include <unistd.h>
+#include <signal.h>
+
 #include <aul.h>
 
 #include "launchpad.h"
@@ -32,6 +34,11 @@ Launchpad::Launchpad(const uid_t uid) :
     }
 }
 
+bool Launchpad::instantiated(const std::string& appid)
+{
+    return ::aul_app_is_running_for_uid(appid.c_str(), user);
+}
+
 int Launchpad::launch(const std::string& appid)
 {
     return launch(appid, Bundle());
@@ -45,3 +52,14 @@ int Launchpad::launch(const std::string& appid, const Bundle& bundle)
 
     return 0;
 }
+
+void Launchpad::terminate(const std::string& appid)
+{
+    int pid = ::aul_app_get_pid_for_uid(appid.c_str(), user);
+    if (pid > 0) {
+        if (::aul_terminate_pid_for_uid(pid, user) < 0) {
+            WARN("Failed to terminate app PID=" + std::to_string(pid));
+            ::kill(pid, SIGKILL);
+        }
+    }
+}
index 76a76e4..f52a892 100644 (file)
@@ -30,6 +30,8 @@ public:
 
     int launch(const std::string& appid);
     int launch(const std::string& appid, const Bundle& bundle);
+    bool instantiated(const std::string& appid);
+    void terminate(const std::string& appid);
 
 private:
     uid_t user;