Skip to content

Commit

Permalink
fix(ocamllsp): use Spawn to launch ppx
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>

ps-id: 3a6f3b4e-0d69-4730-aaa1-c301cae5e9c3
  • Loading branch information
rgrinberg committed Jul 15, 2022
1 parent 1709fc1 commit 9255d4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ocaml-lsp-server/vendor/merlin/src/kernel/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-open Merlin_specific
-open Merlin_extend)
(libraries merlin_config os_ipc ocaml_parsing ocaml_preprocess ocaml_typing ocaml_utils
merlin_extend merlin_specific merlin_utils merlin_dot_protocol))
merlin_extend merlin_specific merlin_utils merlin_dot_protocol spawn))

(rule
(targets standard_library.ml)
Expand Down
14 changes: 13 additions & 1 deletion ocaml-lsp-server/vendor/merlin/src/ocaml/driver/pparse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,19 @@ let merlin_system_command =
windows_merlin_system_command
else
fun cmd ~cwd ->
Sys.command (Printf.sprintf "cd %s && %s" (Filename.quote cwd) cmd)
let prog = "/bin/bash" in
let argv = ["sh"; "-c"; cmd] in
let stdin = Unix.openfile "/dev/null" [ Unix.O_RDONLY ] 0x777 in
let pid = Spawn.spawn ~prog ~argv ~stdin ~stdout:Unix.stderr ~stderr:Unix.stderr () in
let (_, status) = Unix.waitpid [] pid in
let res =
match (status : Unix.process_status) with
| WEXITED n -> n
| WSIGNALED _ -> -1
| WSTOPPED _ -> -1
in
Unix.close stdin;
res

let ppx_commandline cmd fn_in fn_out =
Printf.sprintf "%s %s %s%s"
Expand Down

0 comments on commit 9255d4a

Please sign in to comment.