diff --git a/bin/admin.ml b/bin/admin.ml index dd562e2..28795ad 100644 --- a/bin/admin.ml +++ b/bin/admin.ml @@ -64,9 +64,9 @@ let show () cap_path terse pool worker = let check_exit_status = function | Unix.WEXITED 0 -> () - | Unix.WEXITED x -> Fmt.failwith "Sub-process failed with exit code %d" x - | Unix.WSIGNALED x -> Fmt.failwith "Sub-process failed with signal %d" x - | Unix.WSTOPPED x -> Fmt.failwith "Sub-process stopped with signal %d" x + | Unix.WEXITED x -> Fmt.failwith "Sub-process failed with exit code %a" Logging.pp_exit_status x + | Unix.WSIGNALED x -> Fmt.failwith "Sub-process failed with signal %a" Fmt.Dump.signal x + | Unix.WSTOPPED x -> Fmt.failwith "Sub-process stopped with signal %a" Fmt.Dump.signal x let exec () cap_path pool command = run cap_path @@ fun admin_service -> diff --git a/bin/logging.ml b/bin/logging.ml index 8eaa12d..34ae858 100644 --- a/bin/logging.ml +++ b/bin/logging.ml @@ -1,3 +1,9 @@ +let pp_exit_status f n = + if Sys.win32 && n < 0 then + Fmt.pf f "0x%08lx" (Int32.of_int n) + else + Fmt.int f n + let pp_timestamp f x = let open Unix in let tm = localtime x in diff --git a/bin/worker.ml b/bin/worker.ml index c5b5752..f78cda7 100644 --- a/bin/worker.ml +++ b/bin/worker.ml @@ -14,9 +14,9 @@ let or_die = function let check_exit_status = function | Unix.WEXITED 0 -> () - | Unix.WEXITED x -> Fmt.failwith "Sub-process failed with exit code %d" x - | Unix.WSIGNALED x -> Fmt.failwith "Sub-process failed with signal %d" x - | Unix.WSTOPPED x -> Fmt.failwith "Sub-process stopped with signal %d" x + | Unix.WEXITED x -> Fmt.failwith "Sub-process failed with exit code %a" Logging.pp_exit_status x + | Unix.WSIGNALED x -> Fmt.failwith "Sub-process failed with signal %a" Fmt.Dump.signal x + | Unix.WSTOPPED x -> Fmt.failwith "Sub-process stopped with signal %a" Fmt.Dump.signal x module Self_update = struct let service = "builder_agent" diff --git a/worker/process.ml b/worker/process.ml index f8c0b27..5f0f5bd 100644 --- a/worker/process.ml +++ b/worker/process.ml @@ -41,9 +41,15 @@ let exec ~label ~log ~switch ?env ?(stdin="") ?(stderr=`FD_copy Unix.stdout) ?(i | Unix.WSIGNALED x -> Fmt.error_msg "%s failed with signal %a" label Fmt.Dump.signal x | Unix.WSTOPPED x -> Fmt.error_msg "%s stopped with signal %a" label Fmt.Dump.signal x +let pp_exit_status f n = + if Sys.win32 && n < 0 then + Fmt.pf f "0x%08lx" (Int32.of_int n) + else + Fmt.int f n + let check_call ~label ~log ~switch ?env ?stdin ?stderr ?is_success cmd = exec ~label ~log ~switch ?env ?stdin ?stderr ?is_success cmd >|= function | Ok () -> Ok () | Error `Cancelled -> Error `Cancelled - | Error (`Exit_code n) -> Fmt.error_msg "%s failed with exit-code %d" label n + | Error (`Exit_code n) -> Fmt.error_msg "%s failed with exit-code %a" label pp_exit_status n | Error (`Msg _) as e -> e