Skip to content

Commit

Permalink
Use create_process instead of execvp
Browse files Browse the repository at this point in the history
On Windows, execvp creates a separate process, which can confuse dune
when it is waiting for the mdx process. This causes it to miss that the
output file has been created. This affects mdx's test suite and
possibly users of the mdx stanza. Instead we create a process and
immediately wait for it in the parent.

See realworldocaml#295, ocaml/dune#3849.
  • Loading branch information
emillon committed Nov 13, 2020
1 parent 04bc092 commit c17be4e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ let run (`Setup ()) _ _ _ _ _ _ _ _ _ _ =
let argv = Array.sub Sys.argv 1 (Array.length Sys.argv - 1) in
argv.(0) <- cmd;
Log.debug (fun l -> l "executing %a" Fmt.(Dump.array string) argv);
Unix.execvp cmd argv
let pid = Unix.create_process cmd argv Unix.stdin Unix.stdout Unix.stderr in
let _pid, status = Unix.waitpid [] pid in
let exit_code =
match status with WEXITED n -> n | WSIGNALED _ -> 1 | WSTOPPED _ -> 1
in
exit exit_code

open Cmdliner

Expand Down

0 comments on commit c17be4e

Please sign in to comment.