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

Add ?cloexec parameter to Lwt_io.pipe #911

Merged
merged 1 commit into from
Dec 20, 2021
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
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