vlib: add process restart cli 87/5587/2
authorDamjan Marion <damarion@cisco.com>
Thu, 2 Mar 2017 11:33:48 +0000 (12:33 +0100)
committerFlorin Coras <florin.coras@gmail.com>
Wed, 8 Mar 2017 23:23:40 +0000 (23:23 +0000)
Change-Id: I8b81e53ebea573b4edb17aca7e1c284f3984e399
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vlib/cli.c

index 2d14111..f853f65 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <vlib/vlib.h>
 #include <vppinfra/cpu.h>
+#include <unistd.h>
 
 /* Root of all show commands. */
 /* *INDENT-OFF* */
@@ -757,6 +758,25 @@ VLIB_CLI_COMMAND (cmd_test_heap_validate,static) = {
 };
 /* *INDENT-ON* */
 
+static clib_error_t *
+restart_cmd_fn (vlib_main_t * vm, unformat_input_t * input,
+               vlib_cli_command_t * cmd)
+{
+  char *newenviron[] = { NULL };
+
+  execve (vm->name, (char **) vm->argv, newenviron);
+
+  return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (restart_cmd,static) = {
+    .path = "restart",
+    .short_help = "restart process",
+    .function = restart_cmd_fn,
+};
+/* *INDENT-ON* */
+
 #ifdef TEST_CODE
 /*
  * A trivial test harness to verify the per-process output_function