X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafm-urun.c;h=534f84cefbbd17affacd6b49dd7f9151ce212f8b;hb=3476b426fb3443ff909f8d607934e59601c7d508;hp=8c21b2a4621a89ac928105164838bd3b0ad4db0d;hpb=d40fc40da829be0975411f98212c7c46a13712e9;p=src%2Fapp-framework-main.git diff --git a/src/afm-urun.c b/src/afm-urun.c index 8c21b2a..534f84c 100644 --- a/src/afm-urun.c +++ b/src/afm-urun.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2018 IoT.bzh + Copyright (C) 2015-2019 IoT.bzh author: José Bollo @@ -268,7 +268,7 @@ int afm_urun_once(struct json_object *appli, int uid) } rc = systemd_unit_pid_of_dpath(isuser, udpath); - if (rc < 0) { + if (rc <= 0) { j_read_string_at(appli, "unit-scope", &uscope); j_read_string_at(appli, "unit-name", &uname); ERROR("can't getpid of %s unit %s for uid %d: %m", uscope, uname, uid); @@ -326,7 +326,7 @@ int afm_urun_resume(int runid, int uid) * * Returns the list or NULL in case of error. */ -struct json_object *afm_urun_list(struct afm_udb *db, int uid) +struct json_object *afm_urun_list(struct afm_udb *db, int all, int uid) { int i, n, isuser, pid; const char *udpath; @@ -342,7 +342,7 @@ struct json_object *afm_urun_list(struct afm_udb *db, int uid) if (result == NULL) goto error; - apps = afm_udb_applications_private(db, uid); + apps = afm_udb_applications_private(db, all, uid); n = json_object_array_length(apps); for (i = 0 ; i < n ; i++) { appli = json_object_array_get_idx(apps, i); @@ -393,7 +393,7 @@ struct json_object *afm_urun_state(struct afm_udb *db, int runid, int uid) WARNING("searched runid %d not found", runid); } else { /* search in the base */ - apps = afm_udb_applications_private(db, uid); + apps = afm_udb_applications_private(db, 1, uid); n = json_object_array_length(apps); for (i = 0 ; i < n ; i++) { appli = json_object_array_get_idx(apps, i); @@ -403,7 +403,7 @@ struct json_object *afm_urun_state(struct afm_udb *db, int runid, int uid) && j_read_string_at(appli, "id", &id)) { pid = systemd_unit_pid_of_dpath(isuser, udpath); state = systemd_unit_state_of_dpath(isuser, dpath); - if (state == SysD_State_Active) + if (pid > 0 && state == SysD_State_Active) result = mkstate(id, runid, pid, state); goto end; } @@ -437,6 +437,10 @@ int afm_urun_search_runid(struct afm_udb *db, const char *id, int uid) pid = -1; } else { pid = systemd_unit_pid_of_dpath(isuser, udpath); + if (pid == 0) { + errno = ESRCH; + pid = -1; + } } return pid; }