Skip to content

Commit

Permalink
Add ?cloexec parameter to Lwt_io.pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA committed Dec 6, 2021
1 parent 6eba19d commit eca1c53
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
===== dev =====

====== Additions ======

* In the Lwt_io module, add `?cloexec:bool` optional arguments to functions that create file descriptors (`pipe`). The `?cloexec` argument is simply forwarded to the wrapped Lwt_unix function. (#872, #911, Antonin Décimo)

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

* Fix win32_spawn leaking dev_null fd in the parent process. (#906, Antonin Décimo)
Expand Down
4 changes: 2 additions & 2 deletions src/unix/lwt_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1367,8 +1367,8 @@ let eprintl txt = write_line stderr txt
let eprintf fmt = Printf.ksprintf eprint fmt
let eprintlf fmt = Printf.ksprintf eprintl fmt

let pipe ?in_buffer ?out_buffer _ =
let fd_r, fd_w = Lwt_unix.pipe () in
let pipe ?cloexec ?in_buffer ?out_buffer _ =
let fd_r, fd_w = Lwt_unix.pipe ?cloexec () in
(of_fd ?buffer:in_buffer ~mode:input fd_r,
of_fd ?buffer:out_buffer ~mode:output fd_w)

Expand Down
5 changes: 3 additions & 2 deletions src/unix/lwt_io.mli
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ val null : output_channel

(** {2 Channels creation/manipulation} *)

val pipe : ?in_buffer : Lwt_bytes.t -> ?out_buffer : Lwt_bytes.t -> unit ->
val pipe : ?cloexec : bool ->
?in_buffer : Lwt_bytes.t -> ?out_buffer : Lwt_bytes.t -> unit ->
input_channel * output_channel
(** [pipe ?in_buffer ?out_buffer ()] creates a pipe using
(** [pipe ?cloexec ?in_buffer ?out_buffer ()] creates a pipe using
{!Lwt_unix.pipe} and makes two channels from the two returned file
descriptors *)

Expand Down

0 comments on commit eca1c53

Please sign in to comment.