Skip to content

Commit

Permalink
Merge pull request ocsigen#906 from MisterDA/windows-createprocess-le…
Browse files Browse the repository at this point in the history
…ak-dev-null

Fix win32_spawn leaking dev_null fd in the parent process
  • Loading branch information
smorimoto authored Dec 2, 2021
2 parents a75488c + ec36c97 commit e9b44ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
===== dev =====

====== Fixes ======

* Fix win32_spawn leaking dev_null fd in the parent process. (#906, Antonin Décimo)

===== 5.5.0 =====

====== Deprecations ======
Expand Down
14 changes: 10 additions & 4 deletions src/unix/lwt_process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,21 @@ let win32_spawn
(if prog = "" then None else Some prog) cmdline env cwd
(stdin_fd, stdout_fd, stderr_fd)
in
let close = function
let close fd fd' =
match fd with
| `FD_move fd ->
Unix.close fd
| `Dev_null ->
begin match fd' with
| Some fd' -> Unix.close fd'
| None -> assert false
end
| _ ->
()
in
close stdin;
close stdout;
close stderr;
close stdin stdin_fd;
close stdout stdout_fd;
close stderr stderr_fd;
proc

external win32_wait_job : Unix.file_descr -> int Lwt_unix.job =
Expand Down

0 comments on commit e9b44ce

Please sign in to comment.