added application terminating status
authorJaeho Lee <jaeho81.lee@samsung.com>
Thu, 28 Mar 2013 13:39:06 +0000 (22:39 +0900)
committerJaeho Lee <jaeho81.lee@samsung.com>
Thu, 28 Mar 2013 13:42:42 +0000 (22:42 +0900)
Change-Id: I4906c62ba4c5b7015b56a64813aa0aca44c7b304

Signed-off-by: Jaeho Lee <jaeho81.lee@samsung.com>
am_daemon/amd_appinfo.c
am_daemon/amd_launch.c
am_daemon/amd_status.c
am_daemon/amd_status.h
include/app_sock.h
include/aul.h
packaging/aul.spec
src/launch.c

index c77b62e..3ba94f4 100755 (executable)
@@ -207,7 +207,7 @@ static int _read_pkg_info(struct appinfomgr *cf)
 
        r = pkgmgrinfo_appinfo_get_installed_list(__app_info_insert_handler, cf);
 
-       return 0;
+       return r;
 }
 
 static struct appinfomgr *_init()
index edd2ea5..98d0351 100755 (executable)
@@ -663,7 +663,9 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                }
 
                if (pid > 0) {
-                       if (caller_pid == pid) {
+                       if (_status_get_app_info_status(pid) == STATUS_DYING) {
+                               pid = -ETERMINATING;
+                       } else if (caller_pid == pid) {
                                _D("caller process & callee process is same.[%s:%d]", appid, pid);
                                pid = -ELOCALLAUNCH_ID;
                        } else if ((ret = __nofork_processing(cmd, pid, kb)) < 0) {
@@ -715,7 +717,7 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
        __real_send(fd, pid);
 
        if(pid > 0) {
-               //_status_add_app_info_list(appid, app_path, pid);
+               _status_add_app_info_list(appid, app_path, pid);
                ret = ac_server_check_launch_privilege(appid, appinfo_get_value(ai, AIT_TYPE), pid);
                return ret != AC_R_ERROR ? pid : -1;
        }
index 5112dcb..a17741c 100755 (executable)
@@ -24,6 +24,7 @@
 #include <glib.h>
 #include <aul.h>
 #include <string.h>
+#include <Ecore.h>
 
 #include "amd_config.h"
 #include "amd_status.h"
@@ -67,6 +68,18 @@ int _status_add_app_info_list(char *appid, char *app_path, int pid)
        return 0;
 }
 
+static Eina_Bool __app_terminate_timer_cb(void *data)
+{
+       app_status_info_t *info_t = (app_status_info_t *)data;
+       int ret = 0;
+
+       ret = kill(info_t->pid, SIGKILL);
+       if (ret == -1)
+               _E("send SIGKILL: %s", strerror(errno));
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
 int _status_update_app_info_list(int pid, int status)
 {
        GSList *iter = NULL;
@@ -77,6 +90,9 @@ int _status_update_app_info_list(int pid, int status)
                info_t = (app_status_info_t *)iter->data;
                if(pid == info_t->pid) {
                        info_t->status = status;
+                       if(status == STATUS_DYING) {
+                               ecore_timer_add(2, __app_terminate_timer_cb, info_t);
+                       }
                        break;
                }
        }
@@ -116,6 +132,21 @@ int _status_remove_app_info_list(int pid)
        return 0;
 }
 
+int _status_get_app_info_status(int pid)
+{
+       GSList *iter = NULL;
+       app_status_info_t *info_t = NULL;
+
+       for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+       {
+               info_t = (app_status_info_t *)iter->data;
+               if(pid == info_t->pid) {
+                       return info_t->status;
+               }
+       }
+}
+
+
 int _status_app_is_running(char *appid)
 {
        GSList *iter = NULL;
index de1312f..3ac2a93 100755 (executable)
@@ -24,6 +24,7 @@
 int _status_add_app_info_list(char *appid, char *app_path, int pid);
 int _status_update_app_info_list(int pid, int status);
 int _status_remove_app_info_list(int pid);
+int _status_get_app_info_status(int pid);
 int _status_app_is_running(char *appid);
 int _status_send_running_appinfo(int fd);
 int _status_app_is_running_v2(char *appid);
index a892c90..2b5bfe0 100755 (executable)
@@ -59,6 +59,8 @@ enum app_cmd {
 #define WEB_LAUNCHPAD_PID -3
 #define ELOCALLAUNCH_ID 128
 #define EILLEGALACCESS 127
+#define ETERMINATING 126
+
 
 
 typedef struct _app_pkt_t {
index 8ceeb06..3e0c699 100755 (executable)
@@ -70,6 +70,7 @@ extern "C" {
  * @brief Return values in AUL. 
  */
 typedef enum _aul_return_val {
+       AUL_R_ETERMINATING = -9,        /**< application terminating */
        AUL_R_EILLACC = -8,             /**< Illegal Access */
        AUL_R_LOCAL = -7,               /**< Launch by himself */
        AUL_R_ETIMEOUT = -6,            /**< Timeout */
index bb2c51e..ee22f5b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       aul
 Summary:    App utility library
-Version:    0.0.260
+Version:    0.0.261
 Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0
index 5321700..f8f33d7 100755 (executable)
@@ -118,6 +118,9 @@ SLPAPI int app_send_cmd(int pid, int cmd, bundle *kb)
                case -EILLEGALACCESS:
                        res = AUL_R_EILLACC;
                        break;
+               case -ETERMINATING:
+                       res = AUL_R_ETERMINATING;
+                       break;
                default:
                        res = AUL_R_ERROR;
                }