-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use WSA_FLAG_NO_HANDLE_INHERIT on Windows for cloexec sockets
On Windows, in order to mark sockets non-inheritable (close-on-exec), it is sometimes not sufficient to use SetHandleInformation. There's some explanation why in [1] and [KB2398202]. Introduced in the hotfix [KB2398202] and supported on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later, the flag WSA_FLAG_NO_HANDLE_INHERIT can be used with WSASocket to create a non-inheritable socket. We can still call SetHandleInformation to clear the inheritable flag on the socket in case the flag isn't supported (running on an early Windows Vista or 7). Related OCaml PR: - ocaml/ocaml#10809. [1]: https://stackoverflow.com/questions/12058911/can-tcp-socket-handles-be-set-not-inheritable [KB2398202]: https://support.microsoft.com/en-us/topic/an-application-may-stop-responding-when-the-application-closes-a-socket-connection-or-shuts-down-41321a1f-d80c-6975-98df-ae499d63133c
- Loading branch information
Showing
3 changed files
with
67 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters