[IMPROVE] kill_app
authorAnastasia Lyupa <a.lyupa@samsung.com>
Thu, 12 Dec 2013 13:48:04 +0000 (17:48 +0400)
committerAnastasia Lyupa <a.lyupa@samsung.com>
Mon, 16 Dec 2013 14:28:57 +0000 (18:28 +0400)
check additional paths (/opt/apps, /opt/usr/apps)

Change-Id: Ia76da200dd2ecca77fb40aa6525410cc4efb19a2
Signed-off-by: Anastasia Lyupa <a.lyupa@samsung.com>
daemon/utils.c

index ca6bad53451c1076b32bd8f5ab4c88525dec6836..740088d8f44f75fa65dca6719d16533fe456f8c7 100644 (file)
@@ -464,12 +464,34 @@ pid_t get_pid_by_path(const char *binary_path)
        return pkg_pid;
 }
 
+static int find_alternative_bin_path(const char *binary_path, char *alter_bin_path) {
+       // alternative path may be /opt/apps/... or /opt/usr/apps/...)
+       if (strncmp(binary_path, APPDIR1, strlen(APPDIR1)) == 0) {
+               strcpy(alter_bin_path, APPDIR2);
+               strcat(alter_bin_path, binary_path + strlen(APPDIR1));
+       } else if (strncmp(binary_path, APPDIR2, strlen(APPDIR2)) == 0) {
+               strcpy(alter_bin_path, APPDIR1);
+               strcat(alter_bin_path, binary_path + strlen(APPDIR2));
+       } else {
+               return 1;
+       }
+       return 0;
+}
+
 int kill_app(const char *binary_path)
 {
        pid_t pkg_pid;
+       char alter_bin_path[PATH_MAX];
 
        LOGI("kill %s (%d)\n", binary_path, SIGKILL);
+
        pkg_pid = get_pid_by_path(binary_path);
+
+       if (pkg_pid == 0) {
+               if (find_alternative_bin_path(binary_path, alter_bin_path) == 0)
+                       pkg_pid = get_pid_by_path(alter_bin_path);
+       }
+
        if (pkg_pid != 0) {
                if (kill(pkg_pid, SIGTERM) == -1) {
                        LOGE("cannot kill %d -%d err<%s>\n", pkg_pid, SIGKILL,