Fix a bug about sending app result 84/245184/4
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 5 Oct 2020 07:05:18 +0000 (16:05 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 5 Oct 2020 07:58:33 +0000 (16:58 +0900)
Before sending the app result, AMD should get the process group
by the process ID.

Change-Id: I46302e478832f7d4d22a09e9ecd36d33e55296d6
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_launch.c

index 7879341b652ae94d410ac532eed326459a4d421a..e6216cf8b30f887cd4a9623d8373fdf30cb25f51 100644 (file)
@@ -1561,7 +1561,8 @@ end:
 static int __dispatch_app_result(request_h req)
 {
        bundle *kb;
-       int pid;
+       int caller_pid;
+       int caller_pgid;
        int pgid;
        char tmp_pid[MAX_PID_STR_BUFSZ];
        int res;
@@ -1575,10 +1576,16 @@ static int __dispatch_app_result(request_h req)
        if (kb == NULL)
                return -1;
 
-       pid = __get_caller_pid(kb);
-       if (pid < 0)
+       caller_pid = __get_caller_pid(kb);
+       if (caller_pid < 0)
                return AUL_R_ERROR;
 
+       caller_pgid = getpgid(caller_pid);
+       if (caller_pgid < 0) {
+               _E("getpgid() is failed. caller_pid(%d)", caller_pid);
+               return AUL_R_ERROR;
+       }
+
        pgid = getpgid(_request_get_pid(req));
        if (pgid > 0) {
                snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", pgid);
@@ -1590,7 +1597,7 @@ static int __dispatch_app_result(request_h req)
                return AUL_R_ERROR;
 
        __set_instance_id(kb);
-       app_status = _app_status_find(getpgid(pid));
+       app_status = _app_status_find(caller_pgid);
        appid = _app_status_get_appid(app_status);
 
        _noti_send(AMD_NOTI_MSG_LAUNCH_APP_RESULT_START,
@@ -1601,12 +1608,12 @@ static int __dispatch_app_result(request_h req)
                info = __find_result_info(seq);
 
        if (info) {
-               res = aul_sock_send_bundle_with_fd(info->fd, pid, kb,
+               res = aul_sock_send_bundle_with_fd(info->fd, pgid, kb,
                                AUL_SOCK_NOREPLY);
                __remove_result_info(info);
                __destroy_result_info(info);
        } else {
-               res = aul_sock_send_bundle(pid, target_uid,
+               res = aul_sock_send_bundle(caller_pgid, target_uid,
                                _request_get_cmd(req), kb,
                                AUL_SOCK_NOREPLY);
        }
@@ -1614,7 +1621,7 @@ static int __dispatch_app_result(request_h req)
                res = AUL_R_ERROR;
 
        _noti_send(AMD_NOTI_MSG_LAUNCH_APP_RESULT_END,
-                       pid, target_uid, GINT_TO_POINTER(res), NULL);
+                       caller_pgid, target_uid, GINT_TO_POINTER(res), NULL);
 
        return 0;
 }
@@ -2510,7 +2517,7 @@ static void __set_caller_appinfo(const char *caller_appid, int caller_pid,
 {
        char buf[MAX_PID_STR_BUFSZ];
 
-       snprintf(buf, sizeof(buf), "%d", caller_pid);
+       snprintf(buf, sizeof(buf), "%d", getpgid(caller_pid));
        bundle_del(kb, AUL_K_CALLER_PID);
        bundle_add(kb, AUL_K_CALLER_PID, buf);