STATS: Add more hierarchy to counters.
[vpp.git] / src / vlib / cli.c
index a85fa93..ca8d2ab 100644 (file)
@@ -38,6 +38,7 @@
  */
 
 #include <vlib/vlib.h>
+#include <vlib/unix/unix.h>
 #include <vppinfra/cpu.h>
 #include <unistd.h>
 #include <ctype.h>
@@ -810,7 +811,7 @@ enable_disable_memory_trace (vlib_main_t * vm,
 
   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
-      if (!unformat (line_input, "%U", unformat_vlib_enable_disable, &enable))
+      if (unformat (line_input, "%U", unformat_vlib_enable_disable, &enable))
        ;
       else if (unformat (line_input, "api-segment"))
        api_segment = 1;
@@ -905,9 +906,23 @@ static clib_error_t *
 restart_cmd_fn (vlib_main_t * vm, unformat_input_t * input,
                vlib_cli_command_t * cmd)
 {
-  char *newenviron[] = { NULL };
+  clib_file_main_t *fm = &file_main;
+  clib_file_t *f;
 
-  execve (vm->name, (char **) vm->argv, newenviron);
+  /* environ(7) does not indicate a header for this */
+  extern char **environ;
+
+  /* Close all known open files */
+  /* *INDENT-OFF* */
+  pool_foreach(f, fm->file_pool,
+    ({
+      if (f->file_descriptor > 2)
+        close(f->file_descriptor);
+    }));
+  /* *INDENT-ON* */
+
+  /* Exec ourself */
+  execve (vm->name, (char **) vm->argv, environ);
 
   return 0;
 }