-
Notifications
You must be signed in to change notification settings - Fork 176
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
Windows: make create_process
duplicate non-inheritable std handles
#909
Windows: make create_process
duplicate non-inheritable std handles
#909
Conversation
c8a0986
to
57b43d4
Compare
1c807dd
to
affeedf
Compare
I've just expanded a bit the scope of this PR by switching all internal pipes used in |
affeedf
to
5ebe9e2
Compare
The patch just got merged in ocaml/ocaml! I think this is ready to go right into Lwt. |
Unix.create_process duplicates the handles given to the child process if they're not inheritable. Mimic this behaviour in Lwt for consistency. See the following PRs: - [Unix library: better API for "close-on-exec" over file descriptors ocsigen#650](ocaml/ocaml#650); - [win32unix create_process: duplicate std handles in create_process iff they're not inheritable #10807](ocaml/ocaml#650).
This is done to prevent possible race conditions, and for consistency. The spawn function is now responsible for ensuring that file descriptors can be inherited by subprocesses (this is always the case on unix when using dup2, but can be trickier on Windows). We can also remove to_close file descriptors in Lwt_process spawn, because the file descriptors are the parent's end of the pipes which must be closed in the child; however switching the pipes to cloexec means they won't be inherited by the child at all.
5ebe9e2
to
9de01c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again I can't test the windows side of things, but the code LGTM. Thank you for the added tests.
Unix.create_process
currently always duplicates the handles given tothe child process to make sure they're inheritable (keep-on-exec). I
have opened the PR 10807 on OCaml to duplicate the handles only if
they're not inheritable (close-on-exec).
This PR mimic this behaviour in Lwt for consistency (assuming the
OCaml PR will be accepted).
See the following PRs:
create_process
: duplicate std handles increate_process
iff they're not inheritable ocaml/ocaml#10807.