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): fix in pp handling the file permissions #1153

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Unreleased

## Fixes

- Fix file permissions used when specifying output files of pp and ppx. (#1153)

# 1.16.1

## Fixes
Expand Down
9 changes: 5 additions & 4 deletions ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -878,20 +878,21 @@ let run_in_directory ~prog ~prog_is_quoted:_ ~args ~cwd ?stdin ?stdout ?stderr
let argv = [ "sh"; "-c"; cmd ] in
let stdin =
match stdin with
| Some file -> Unix.openfile file [ Unix.O_WRONLY ] 0x664
| None -> Unix.openfile "/dev/null" [ Unix.O_RDONLY ] 0x777
| Some file -> Unix.openfile file [ Unix.O_WRONLY ] 0o664
jboillot marked this conversation as resolved.
Show resolved Hide resolved
| None -> Unix.openfile "/dev/null" [ Unix.O_RDONLY ] 0o777
in
let stdout, should_close_stdout =
match stdout with
| Some file -> (Unix.openfile file [ Unix.O_WRONLY ] 0x664, true)
| Some file ->
(Unix.openfile file [ Unix.O_WRONLY; Unix.O_CREAT ] 0o664, true)
| None ->
(* Runned programs should never output to stdout since it is the channel
used by LSP to communicate with the editor *)
(Unix.stderr, false)
in
let stderr =
Option.map stderr ~f:(fun file ->
Unix.openfile file [ Unix.O_WRONLY ] 0x664)
Unix.openfile file [ Unix.O_WRONLY; Unix.O_CREAT ] 0o664)
in
let pid =
let cwd : Spawn.Working_dir.t = Path cwd in
Expand Down