1048
/* Get the PIDs for an AppID. If it's click or legacy single instance that's
1049
a simple call to the helper. But if it's not, we have to make a call for
1050
each instance of the app that we have running. */
1052
pids_for_appid (const gchar * appid)
1054
GDBusConnection * cgmanager = cgroup_manager_connection();
1055
g_return_val_if_fail(cgmanager != NULL, NULL);
1057
if (is_click(appid)) {
1058
GList * pids = pids_from_cgroup(cgmanager, "application-click", appid);
1059
g_clear_object(&cgmanager);
1061
} else if (legacy_single_instance(appid)) {
1062
gchar * jobname = g_strdup_printf("%s-", appid);
1063
GList * pids = pids_from_cgroup(cgmanager, "application-legacy", jobname);
1065
g_clear_object(&cgmanager);
1069
/* If we're not single instance, we need to find all the pids for all
1070
the instances of the app */
1072
GDBusConnection * con = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
1073
g_return_val_if_fail(con != NULL, NULL);
1075
GList * pids = NULL;
1077
GArray * apps = g_array_new(TRUE, TRUE, sizeof(gchar *));
1078
g_array_set_clear_func(apps, free_helper);
1080
apps_for_job(con, "application-legacy", apps, FALSE);
1081
gchar * appiddash = g_strdup_printf("%s-", appid); /* Probably could go RegEx here, but let's start with just a prefix lookup */
1082
for (i = 0; i < apps->len; i++) {
1083
const gchar * array_id = g_array_index(apps, const gchar *, i);
1084
if (g_str_has_prefix(array_id, appiddash)) {
1085
GList * morepids = pids_from_cgroup(cgmanager, "application-legacy", array_id);
1086
pids = g_list_concat(pids, morepids);
1091
g_array_free(apps, TRUE);
1092
g_object_unref(con);
1094
g_clear_object(&cgmanager);
1100
1049
ubuntu_app_launch_pid_in_app_id (GPid pid, const gchar * appid)