mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 14:49:29 +00:00
Inherit handles only if necessary on Windows
Refs #2779 <https://github.com/Genymobile/scrcpy/issues/2779>
This commit is contained in:
parent
dcf9887f56
commit
020b3510ae
1 changed files with 5 additions and 3 deletions
|
@ -26,6 +26,8 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle,
|
||||||
HANDLE *pin, HANDLE *pout, HANDLE *perr) {
|
HANDLE *pin, HANDLE *pout, HANDLE *perr) {
|
||||||
enum sc_process_result ret = SC_PROCESS_ERROR_GENERIC;
|
enum sc_process_result ret = SC_PROCESS_ERROR_GENERIC;
|
||||||
|
|
||||||
|
bool inherit_handles = pin || pout || perr;
|
||||||
|
|
||||||
SECURITY_ATTRIBUTES sa;
|
SECURITY_ATTRIBUTES sa;
|
||||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||||
sa.lpSecurityDescriptor = NULL;
|
sa.lpSecurityDescriptor = NULL;
|
||||||
|
@ -69,7 +71,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle,
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
memset(&si, 0, sizeof(si));
|
memset(&si, 0, sizeof(si));
|
||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
if (pin || pout || perr) {
|
if (inherit_handles) {
|
||||||
si.dwFlags = STARTF_USESTDHANDLES;
|
si.dwFlags = STARTF_USESTDHANDLES;
|
||||||
if (pin) {
|
if (pin) {
|
||||||
si.hStdInput = stdin_read_handle;
|
si.hStdInput = stdin_read_handle;
|
||||||
|
@ -95,8 +97,8 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle,
|
||||||
goto error_close_stderr;
|
goto error_close_stderr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CreateProcessW(NULL, wide, NULL, NULL, TRUE, 0, NULL, NULL, &si,
|
if (!CreateProcessW(NULL, wide, NULL, NULL, inherit_handles, 0, NULL, NULL,
|
||||||
&pi)) {
|
&si, &pi)) {
|
||||||
free(wide);
|
free(wide);
|
||||||
*handle = NULL;
|
*handle = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue