Terminate sub app 66/301066/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 8 Nov 2023 03:45:56 +0000 (12:45 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 8 Nov 2023 03:45:56 +0000 (12:45 +0900)
If the leader process is terminated while executing an application,
amd should terminate the sub application.
And, when the application type is not a component-based application,
the process must be terminated even though the process does not handle
the termination request properly.

Change-Id: If06788d09dc22a6c16437a418ed23d7357da0826
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_launch.c
src/modules/ui-core/src/app_group.c

index e2b27df..7b41587 100644 (file)
@@ -494,11 +494,28 @@ static int __send_app_request(pid_t pid, uid_t uid, int cmd, int clifd,
                .cmd = cmd,
                .data = data
        };
+       app_status_h app_status;
 
        info = __create_reply_info(pid, uid, cmd, clifd, data);
        if (!info)
                return -ENOMEM;
 
+       if (cmd == APP_TERM_BY_PID_ASYNC ||
+                       cmd == APP_TERM_BY_PID ||
+                       cmd == APP_TERM_INSTANCE_ASYNC ||
+                       cmd == APP_TERM_REQ_BY_PID ||
+                       cmd == APP_TERM_BY_PID_SYNC) {
+               app_status = _app_status_find(pid);
+               if (cmd != APP_TERM_INSTANCE_ASYNC ||
+                               _app_status_get_app_type(app_status) !=
+                               AT_COMPONENT_BASED_APP) {
+                       _app_status_update_status(app_status,
+                                       STATUS_DYING,
+                                       false, true);
+               }
+       }
+
+
        ret = amd_app_request_broker_send(&request,
                        __app_request_result_handler, info);
        if (ret < 0) {
@@ -508,7 +525,7 @@ static int __send_app_request(pid_t pid, uid_t uid, int cmd, int clifd,
 
        _anr_monitor_add_timer(pid, cmd);
 
-       return 0;
+       return ret;
 }
 
 int _resume_app(int pid, request_h req)
index e493596..c3e14da 100644 (file)
@@ -865,6 +865,12 @@ static struct app_group_context_s *__app_group_add(
        found = g_list_find_custom(__app_group_list, leader_id,
                        __compare_group_id);
        if (!found) {
+               if (leader_pid != pid) {
+                       _E("%d is not leader(%d)", pid, leader_pid);
+                       __destroy_app_group_context(ctx);
+                       return NULL;
+               }
+
                group = __create_app_group(leader_id, leader_pid);
                if (!group) {
                        _E("Failed to create app group. %s:%d",
@@ -935,6 +941,8 @@ static void __app_group_start(pid_t leader_pid, const char *leader_id,
        bool attach_below = false;
        app_group_node_h caller_node;
        app_group_node_h next_node;
+       amd_app_status_h app_status;
+       uid_t uid;
 
        _D("app_group_start");
 
@@ -970,6 +978,13 @@ static void __app_group_start(pid_t leader_pid, const char *leader_id,
                ctx = __app_group_add(leader_pid, leader_id, pid, id,
                                caller_pid, caller_id, launch_mode,
                                false, recycle, before_wid, attach_below);
+               if (!ctx) {
+                       app_status = amd_app_status_find_by_pid(pid);
+                       if (app_status) {
+                               uid = amd_app_status_get_uid(app_status);
+                               amd_launch_term_sub_inst(pid, id, uid);
+                       }
+               }
        } else {
                ctx = __app_group_add(pid, id, pid, id,
                                caller_pid, caller_id, launch_mode,