diff options
author | José Bollo <jose.bollo@iot.bzh> | 2017-07-11 17:31:42 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2017-07-11 17:40:20 +0200 |
commit | 92736672c93cb9cc159af5dbc831249eb15261ed (patch) | |
tree | df5f01b34848aca19a078372b0e34b4dd07f2d42 | |
parent | 69ead37e1a16301839ca62d48235e93bb0cc580e (diff) |
Don't list terminated processes
Listing processes that are terminated
might be disturbing. So it is now removed.
In some future, it should be good to return on
option even terminated processes with an indication
of their termination status.
Bug-AGL: SPEC-728
Change-Id: I6d5c892bc5e618830cb41de7d664c2443525af96
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r-- | src/afm-urun.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/afm-urun.c b/src/afm-urun.c index d6185c8..1814437 100644 --- a/src/afm-urun.c +++ b/src/afm-urun.c @@ -290,10 +290,12 @@ struct json_object *afm_urun_list(struct afm_udb *db) pid = systemd_unit_pid_of_dpath(isuser, udpath); if (pid > 0 && j_read_string_at(appli, "id", &id)) { state = systemd_unit_state_of_dpath(isuser, udpath); - desc = mkstate(id, pid, pid, state); - if (desc && json_object_array_add(result, desc) == -1) { - ERROR("can't add desc %s to result", json_object_get_string(desc)); - json_object_put(desc); + if (state == SysD_State_Active) { + desc = mkstate(id, pid, pid, state); + if (desc && json_object_array_add(result, desc) == -1) { + ERROR("can't add desc %s to result", json_object_get_string(desc)); + json_object_put(desc); + } } } } @@ -325,7 +327,6 @@ struct json_object *afm_urun_state(struct afm_udb *db, int runid) /* get the dpath */ dpath = systemd_unit_dpath_by_pid(1 /* TODO: isuser? */, (unsigned)runid); if (!dpath) { - result = NULL; errno = EINVAL; WARNING("searched runid %d not found", runid); } else { @@ -340,11 +341,11 @@ struct json_object *afm_urun_state(struct afm_udb *db, int runid) && j_read_string_at(appli, "id", &id)) { pid = systemd_unit_pid_of_dpath(isuser, udpath); state = systemd_unit_state_of_dpath(isuser, dpath); - result = mkstate(id, runid, pid, state); + if (state == SysD_State_Active) + result = mkstate(id, runid, pid, state); goto end; } } - result = NULL; errno = ENOENT; WARNING("searched runid %d of dpath %s isn't an applications", runid, dpath); end: |