vlib: add graceful termination with status
[vpp.git] / src / vlib / main.c
index c7c4aba..2f21995 100644 (file)
@@ -2079,7 +2079,7 @@ done:
   if (error)
     clib_error_report (error);
 
-  return 0;
+  return vm->main_loop_exit_status;
 }
 
 vlib_main_t *
@@ -2094,6 +2094,13 @@ vlib_get_elog_main_not_inline ()
   return &vlib_global_main.elog_main;
 }
 
+void
+vlib_exit_with_status (vlib_main_t *vm, int status)
+{
+  vm->main_loop_exit_status = status;
+  __atomic_store_n (&vm->main_loop_exit_now, 1, __ATOMIC_RELEASE);
+}
+
 /*
  * fd.io coding-style-patch-verification: ON
  *