From cb999ca1c42406ab131399bdcd7135b0745dfdf1 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 10 Jan 2023 23:56:50 +0000 Subject: [PATCH] Check process group ID for getting appid and pkgid The web engine is running as a child process of the web app. If the web engine calls AUL APIs, the request is delivered to AMD. Because, the process ID is not equal to the web app. After this patch is applied, AUL API checks whether the process group ID is equal to the process ID or not. Before executing an application, the child process of the launchpad-process-pool calls the setsid() to run the process in a new session. In that time, the process group is separated from the launchpad-process-pool. Checking the process group ID can reduce the IPC between AMD and the caller process. Change-Id: I3746046c36328ecacc27c6cda16afbe44c1e1cfd Signed-off-by: Hwankyu Jhun --- src/pkginfo.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pkginfo.cc b/src/pkginfo.cc index d70cf6b..d1f0483 100644 --- a/src/pkginfo.cc +++ b/src/pkginfo.cc @@ -301,7 +301,7 @@ extern "C" API int aul_app_get_appid_bypid_for_uid(int pid, char* appid, return AUL_R_EINVAL; } - if (getpid() == pid) { + if (getpid() == pid || getpgid(getpid()) == pid) { context.Initialize(); auto& preinit_appid = context.GetPreInitAppId(); if (!preinit_appid.empty()) { @@ -341,7 +341,7 @@ extern "C" API int aul_app_get_pkgid_bypid_for_uid(int pid, char* pkgid, return AUL_R_EINVAL; } - if (getpid() == pid) { + if (getpid() == pid || getpgid(getpid()) == pid) { context.Initialize(); auto& preinit_pkgid = context.GetPreInitPkgId(); if (!preinit_pkgid.empty()) { -- 2.7.4