[Concept,02/19] sandbox: Use sandbox_exit() for -c command path

Message ID 20260314231618.338113-3-sjg@u-boot.org
State New
Headers
Series test: Fix pytest inter-test side effects |

Commit Message

Simon Glass March 14, 2026, 11:15 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

The -c command path calls os_exit() directly, bypassing state_uninit().
This means cleanup actions like writing the malloc dump are skipped.

Use sandbox_exit() instead, which calls state_uninit() before exiting.
Now that sandbox_exit() accepts an exit code, the command return value
is still propagated correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/start.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index b9f48376d22..7c9f0a99654 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -158,7 +158,7 @@  int sandbox_main_loop_init(void)
 							0);
 #endif
 		if (!state->interactive)
-			os_exit(retval);
+			sandbox_exit(retval);
 	}
 
 	return 0;
@@ -583,7 +583,7 @@  void __efi_runtime EFIAPI efi_reset_system(
 		unsigned long data_size, void *reset_data)
 {
 	if (reset_type == EFI_RESET_SHUTDOWN)
-		sandbox_exit();
+		sandbox_exit(0);
 	else
 		sandbox_reset();
 }