summaryrefslogtreecommitdiffabout
path: root/src/ctl.c
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-05 15:42:13 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-01-05 16:31:05 (GMT)
commit7dd7f4e2d7a5eaed676651caf456c1de0704b7cd (patch) (side-by-side diff)
tree2073caae8a686914c84b5bde8bcdf59331240ea6 /src/ctl.c
parent6ac0f1e8e19922c63a1542740a7c88116989bb7c (diff)
downloadpies-7dd7f4e2d7a5eaed676651caf456c1de0704b7cd.tar.gz
pies-7dd7f4e2d7a5eaed676651caf456c1de0704b7cd.tar.bz2
Include argv in the output of ctl id command.
* ctl.c (res_instance): Include "argv" in the return json. Use pies_master_argv[0] to report binary path. * pies.c (pies_master_argv,pies_master_argc): New globals. (main): Initialize them. Refuse to restart unless argv[0] begins with a slash. * pies.h (pies_master_argv,pies_master_argc): New globals. * piesctl.c (com_id): Rewrite output formatting.
Diffstat (limited to 'src/ctl.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/ctl.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/ctl.c b/src/ctl.c
index cdb9b6c..8845390 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -1299,6 +1299,23 @@ idfmt_pid (struct ctlio *io, char const *name, void *ptr)
}
static void
+idfmt_argv (struct ctlio *io, char const *name, void *ptr)
+{
+ struct json_value *ar = json_new_array ();
+ size_t i;
+
+ for (i = 0; i < pies_master_argc; i++)
+ json_array_append (ar, json_new_string (pies_master_argv[i]));
+ json_object_set (io->output.reply, name, ar);
+}
+
+static void
+idfmt_binary (struct ctlio *io, char const *name, void *ptr)
+{
+ json_object_set_string (io->output.reply, name, "%s", pies_master_argv[0]);
+}
+
+static void
res_instance (struct ctlio *io, enum http_method meth,
char const *uri, struct json_value *req)
{
@@ -1309,11 +1326,10 @@ res_instance (struct ctlio *io, enum http_method meth,
} idparam[] = {
{ "package", idfmt_string, PACKAGE_NAME },
{ "version", idfmt_string, PACKAGE_VERSION },
-#if HAVE_DECL_PROGRAM_INVOCATION_NAME
- { "binary", idfmt_string_ptr, &program_invocation_name },
-#endif
+ { "binary", idfmt_binary, NULL },
{ "PID", idfmt_pid, NULL },
{ "instance", idfmt_string_ptr, &instance },
+ { "argv", idfmt_argv, NULL },
{ NULL }
};
struct idparam *p;

Return to:

Send suggestions and report system problems to the System administrator.