From 94dcf76eb2d65c5f5a40f83d855cd17ef6655cc3 Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Mon, 14 Oct 2024 13:40:05 +0100 Subject: [PATCH] Make error messages more descriptive Recently was trying to start podman machine with krunkit and got: Error: krunkit exited unexpectedly with exit code 1 which isn't very descriptive. Although this doesn't solve the issue, it increases the debugability of this error. Signed-off-by: Eric Curtin --- pkg/machine/apple/apple.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/machine/apple/apple.go b/pkg/machine/apple/apple.go index 73fdd5b2d5..4f720b80af 100644 --- a/pkg/machine/apple/apple.go +++ b/pkg/machine/apple/apple.go @@ -360,8 +360,14 @@ func CheckProcessRunning(processName string, pid int) error { return fmt.Errorf("failed to read %s process status: %w", processName, err) } if pid > 0 { - // child exited - return fmt.Errorf("%s exited unexpectedly with exit code %d", processName, status.ExitStatus()) + // Child exited, process is no longer running + if status.Exited() { + return fmt.Errorf("%s exited unexpectedly with exit code %d", processName, status.ExitStatus()) + } + if status.Signaled() { + return fmt.Errorf("%s was terminated by signal: %s", processName, status.Signal().String()) + } + return fmt.Errorf("%s exited unexpectedly", processName) } return nil }