-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Inherit only specific handles on Windows #2783
Merged
Merged
Conversation
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 was referenced Nov 14, 2021
84dcb85
to
f6a3f24
Compare
To be able to communicate with a child process via stdin, stdout and stderr, the CreateProcess() parameter bInheritHandles must be set to TRUE. But this causes *all* handles to be inherited, including sockets. As a result, the server socket was inherited by the process running adb to execute the server on the device, so it could not be closed properly, causing other scrcpy instances to fail. To fix the issue, use an extended API to explicitly set the HANDLEs to inherit: - <https://stackoverflow.com/a/28185363/1987178> - <https://devblogs.microsoft.com/oldnewthing/20111216-00/?p=8873> Fixes #2779 <#2779>
f6a3f24
to
1eaa73d
Compare
rom1v
added a commit
that referenced
this pull request
Nov 15, 2021
To be able to communicate with a child process via stdin, stdout and stderr, the CreateProcess() parameter bInheritHandles must be set to TRUE. But this causes *all* handles to be inherited, including sockets. As a result, the server socket was inherited by the process running adb to execute the server on the device, so it could not be closed properly, causing other scrcpy instances to fail. To fix the issue, use an extended API to explicitly set the HANDLEs to inherit: - <https://stackoverflow.com/a/28185363/1987178> - <https://devblogs.microsoft.com/oldnewthing/20111216-00/?p=8873> Fixes #2779 <#2779> PR #2783 <#2783>
Merged into |
This was referenced Nov 16, 2021
Closed
2 tasks
Closed
rom1v
added a commit
that referenced
this pull request
Nov 30, 2021
According to this bug report on Firefox: <https://bugzilla.mozilla.org/show_bug.cgi?id=1460995> > CreateProcess fails with ERROR_NO_SYSTEM_RESOURCES on Windows 7. It > looks like the reason why is because PROC_THREAD_ATTRIBUTE_HANDLE_LIST > doesn't like console handles. To avoid the problem, do not pass console handles to PROC_THREAD_ATTRIBUTE_HANDLE_LIST. Refs #2783 <#2783> Refs f801d8b Fixes #2838 <#2838>
rom1v
added a commit
that referenced
this pull request
Dec 1, 2021
According to this bug report on Firefox: <https://bugzilla.mozilla.org/show_bug.cgi?id=1460995> > CreateProcess fails with ERROR_NO_SYSTEM_RESOURCES on Windows 7. It > looks like the reason why is because PROC_THREAD_ATTRIBUTE_HANDLE_LIST > doesn't like console handles. To avoid the problem, do not pass console handles to PROC_THREAD_ATTRIBUTE_HANDLE_LIST. Refs #2783 <#2783> Refs f801d8b Fixes #2838 <#2838> PR #2840 <#2840>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inherit only specific handles on Windows
To be able to communicate with a child process via
stdin
,stdout
andstderr
, theCreateProcess()
parameterbInheritHandles
must be set toTRUE
. But this causes all handles to be inherited, including sockets.As a result, the server socket was inherited by the process running adb
to execute the server on the device, so it could not be closed properly,
causing other scrcpy instances to fail.
To fix the issue, use an extended API to explicitly set the
HANDLE
s toinherit:
Fixes #2779
Replace these binaries in your v1.20 release:
scrcpy.exe
sha256:33a57452cbd58c689a30497c28e005111553e2ab21f6ddfee270767c29b5ccebscrcpy-server
sha256:b20aee4951f99b060c4a44000ba94de973f9604758ef62beb253b371aad3df34