aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-11-08 13:06:28 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2016-11-08 13:06:28 +0100
commitd7890b93b8a0a9d0cd96b07f4b4e1326a52bc012 (patch)
tree744811676db0dbfdcaf98ee2d4cd1dd04f95ddbb
parent59e224c962345fdc30e3c67aa90627ad8771becf (diff)
afm-user-daemon: returns the pids of the processes
Asking for the state now returns the pids of the launched processes when this processes are still alive. Change-Id: I69348d8089581247465c3bd1ab83f86decad25ae Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--docs/afm-user-daemon.md4
-rw-r--r--src/afm-run.c19
2 files changed, 21 insertions, 2 deletions
diff --git a/docs/afm-user-daemon.md b/docs/afm-user-daemon.md
index f1ce7f8..ad625e9 100644
--- a/docs/afm-user-daemon.md
+++ b/docs/afm-user-daemon.md
@@ -672,13 +672,15 @@ The field "mode" is a string equal to either "local" or "remote".
**Input**: The *runid* (integer) of the running instance inspected.
**output**: An object describing instance state. It contains:
-the runid (integer), the id of the running application (string),
+the runid (integer), the pids of the processes as an array starting
+with the group leader, the id of the running application (string),
the state of the application (string either: "starting", "running", "stopped").
Example of returned state:
{
"runid": 2,
+ "pids": [ 435, 436 ],
"state": "running",
"id": "appli@x.y"
}
diff --git a/src/afm-run.c b/src/afm-run.c
index 18824f9..4de0fd2 100644
--- a/src/afm-run.c
+++ b/src/afm-run.c
@@ -421,7 +421,7 @@ static int fill_launch_desc(struct json_object *appli,
static json_object *mkstate(struct apprun *runner)
{
const char *state;
- struct json_object *result, *obj;
+ struct json_object *result, *obj, *pids;
int rc;
/* the structure */
@@ -433,6 +433,23 @@ static json_object *mkstate(struct apprun *runner)
if (!j_add_integer(result, "runid", runner->runid))
goto error2;
+ /* the pids */
+ switch(runner->state) {
+ case as_starting:
+ case as_running:
+ case as_stopped:
+ pids = j_add_new_array(result, "pids");
+ if (!pids)
+ goto error2;
+ if (!j_add_integer(pids, NULL, runner->pids[0]))
+ goto error2;
+ if (runner->pids[1] && !j_add_integer(pids, NULL, runner->pids[1]))
+ goto error2;
+ break;
+ default:
+ break;
+ }
+
/* the state */
switch(runner->state) {
case as_starting: