Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ocamllsp): use Spawn to launch ppx #788

Merged
merged 1 commit into from
Jul 15, 2022
Merged
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
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