Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/admin.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
6 changes: 6 additions & 0 deletions bin/logging.ml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions bin/worker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion worker/process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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