Skip to content

Commit

Permalink
engine/Local_backend: improved error reporting
Browse files Browse the repository at this point in the history
in the case a child process dies. Before it would just raise an
End_of_file exception.
  • Loading branch information
pveber committed Mar 24, 2020
1 parent f69dbbb commit 8744938
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/engine/local_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@ let eval _ () f x =
Unix.close write_to_parent ;
Unix.close read_from_parent ;
let ic = Lwt_io.of_unix_fd ~mode:Lwt_io.input read_from_child in
Lwt_io.read_value ic >>= fun (res : (unit, string) result) ->
Caml.Unix.kill (Pid.to_int pid) Caml.Sys.sigkill;
Misc.waitpid (Pid.to_int pid) >>= fun _ ->
Unix.close read_from_child ;
Unix.close write_to_child ;
Lwt.return res
Lwt.catch
(fun () ->
Lwt_io.read_value ic >>= fun (res : (unit, string) result) ->
Caml.Unix.kill (Pid.to_int pid) Caml.Sys.sigkill;
Misc.waitpid (Pid.to_int pid) >>= fun _ ->
Unix.close read_from_child ;
Unix.close write_to_child ;
Lwt.return res)
(function
| End_of_file ->
Lwt_result.fail "Lost communication with child process (End_of_file due to segfault?)"
| exn ->
let msg = Exn.to_string exn in
Lwt_result.fail ("Lost communication with child process: " ^ msg))

let build_trace backend w requirement perform =
let ready = Unix.gettimeofday () in
Expand Down

0 comments on commit 8744938

Please sign in to comment.