**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"
}
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 */
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: