From 5e0f15d76b876a039d94dcd4c628cc38dc02a698 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 15 Oct 2025 22:09:33 +0900 Subject: hst/container: additional shim exit codes These are now considered stable, defined behaviour and can be used by external programs to determine shim outcome. Signed-off-by: Ophestra --- internal/app/shim.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'internal/app/shim.go') diff --git a/internal/app/shim.go b/internal/app/shim.go index 1fdedd32..992215fb 100644 --- a/internal/app/shim.go +++ b/internal/app/shim.go @@ -23,14 +23,11 @@ import ( //#include "shim-signal.h" import "C" -const ( - // setup pipe fd for [container.Receive] - shimEnv = "HAKUREI_SHIM" - - // only used for a nil configured env map - envAllocSize = 1 << 6 -) +// shimEnv is the name of the environment variable storing decimal representation of +// setup pipe fd for [container.Receive]. +const shimEnv = "HAKUREI_SHIM" +// shimParams is embedded in outcomeState and transmitted from priv side to shim. type shimParams struct { // Priv side pid, checked against ppid in signal handler for the syscall.SIGCONT hack. PrivPID int @@ -172,7 +169,7 @@ func ShimMain() { if err := z.Start(); err != nil { printMessageError("cannot start container:", err) - os.Exit(1) + os.Exit(hst.ShimExitFailure) } if err := z.Serve(); err != nil { printMessageError("cannot configure container:", err) @@ -189,7 +186,7 @@ func ShimMain() { var exitError *exec.ExitError if !errors.As(err, &exitError) { if errors.Is(err, context.Canceled) { - os.Exit(2) + os.Exit(hst.ShimExitCancel) } log.Printf("wait: %v", err) os.Exit(127) -- cgit v1.3.1