From 70096b533d42b684ab13651aaae884047e01e43d Mon Sep 17 00:00:00 2001 From: James O'Doherty Date: Fri, 29 May 2026 19:21:49 -0400 Subject: refactor: optimize file cleanups, propagate exit codes, and fix Makefile - Unlink the temporary bootstrap launcher binary immediately after opening a read-only descriptor to it, then execute via `/proc/self/fd/` to ensure zero-disk footprint on execution. - Unlink temporary `/tmp/resolvconf*` files immediately after successful bind-mounting over `/etc/resolv.conf`. - Prune parent ephemeral profile directories when unpinning a namespace, leaving zero directories behind once empty. - Propagate the exact exit status of the wrapped command to the host process using `errors.As` and `*exec.ExitError` instead of defaulting to exit code 1. - Added E2E automated test `TestExitCodePropagation` to verify exit status delivery. - Added the `$(BINARY)` target to `.PHONY` in the Makefile to delegate dependency tracking to Go's compiler cache, ensuring modified Go files are rebuilt during `make test`. --- internal/namespace/pinning.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'internal/namespace/pinning.go') diff --git a/internal/namespace/pinning.go b/internal/namespace/pinning.go index 7976937..eb0a376 100644 --- a/internal/namespace/pinning.go +++ b/internal/namespace/pinning.go @@ -44,8 +44,10 @@ func UnpinNamespace(pm *paths.PathManager, profile string) error { return fmt.Errorf("failed to unpin namespace %s: %w", nsPath, err) } - // Try to remove pids directory + // Try to remove pids directory and empty parent directories _ = os.Remove(pidsDir) + _ = os.Remove(filepath.Dir(pidsDir)) + _ = os.Remove(filepath.Dir(filepath.Dir(pidsDir))) return nil } -- cgit v1.2.3