Loading adb/adb.c +21 −0 Original line number Original line Diff line number Diff line Loading @@ -991,6 +991,7 @@ int launch_server(int server_port) /* message since the pipe handles must be inheritable, we use a */ /* message since the pipe handles must be inheritable, we use a */ /* security attribute */ /* security attribute */ HANDLE pipe_read, pipe_write; HANDLE pipe_read, pipe_write; HANDLE stdout_handle, stderr_handle; SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa; STARTUPINFO startup; STARTUPINFO startup; PROCESS_INFORMATION pinfo; PROCESS_INFORMATION pinfo; Loading @@ -1010,6 +1011,26 @@ int launch_server(int server_port) SetHandleInformation( pipe_read, HANDLE_FLAG_INHERIT, 0 ); SetHandleInformation( pipe_read, HANDLE_FLAG_INHERIT, 0 ); /* Some programs want to launch an adb command and collect its output by * calling CreateProcess with inheritable stdout/stderr handles, then * using read() to get its output. When this happens, the stdout/stderr * handles passed to the adb client process will also be inheritable. * When starting the adb server here, care must be taken to reset them * to non-inheritable. * Otherwise, something bad happens: even if the adb command completes, * the calling process is stuck while read()-ing from the stdout/stderr * descriptors, because they're connected to corresponding handles in the * adb server process (even if the latter never uses/writes to them). */ stdout_handle = GetStdHandle( STD_OUTPUT_HANDLE ); stderr_handle = GetStdHandle( STD_ERROR_HANDLE ); if (stdout_handle != INVALID_HANDLE_VALUE) { SetHandleInformation( stdout_handle, HANDLE_FLAG_INHERIT, 0 ); } if (stderr_handle != INVALID_HANDLE_VALUE) { SetHandleInformation( stderr_handle, HANDLE_FLAG_INHERIT, 0 ); } ZeroMemory( &startup, sizeof(startup) ); ZeroMemory( &startup, sizeof(startup) ); startup.cb = sizeof(startup); startup.cb = sizeof(startup); startup.hStdInput = GetStdHandle( STD_INPUT_HANDLE ); startup.hStdInput = GetStdHandle( STD_INPUT_HANDLE ); Loading Loading
adb/adb.c +21 −0 Original line number Original line Diff line number Diff line Loading @@ -991,6 +991,7 @@ int launch_server(int server_port) /* message since the pipe handles must be inheritable, we use a */ /* message since the pipe handles must be inheritable, we use a */ /* security attribute */ /* security attribute */ HANDLE pipe_read, pipe_write; HANDLE pipe_read, pipe_write; HANDLE stdout_handle, stderr_handle; SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa; STARTUPINFO startup; STARTUPINFO startup; PROCESS_INFORMATION pinfo; PROCESS_INFORMATION pinfo; Loading @@ -1010,6 +1011,26 @@ int launch_server(int server_port) SetHandleInformation( pipe_read, HANDLE_FLAG_INHERIT, 0 ); SetHandleInformation( pipe_read, HANDLE_FLAG_INHERIT, 0 ); /* Some programs want to launch an adb command and collect its output by * calling CreateProcess with inheritable stdout/stderr handles, then * using read() to get its output. When this happens, the stdout/stderr * handles passed to the adb client process will also be inheritable. * When starting the adb server here, care must be taken to reset them * to non-inheritable. * Otherwise, something bad happens: even if the adb command completes, * the calling process is stuck while read()-ing from the stdout/stderr * descriptors, because they're connected to corresponding handles in the * adb server process (even if the latter never uses/writes to them). */ stdout_handle = GetStdHandle( STD_OUTPUT_HANDLE ); stderr_handle = GetStdHandle( STD_ERROR_HANDLE ); if (stdout_handle != INVALID_HANDLE_VALUE) { SetHandleInformation( stdout_handle, HANDLE_FLAG_INHERIT, 0 ); } if (stderr_handle != INVALID_HANDLE_VALUE) { SetHandleInformation( stderr_handle, HANDLE_FLAG_INHERIT, 0 ); } ZeroMemory( &startup, sizeof(startup) ); ZeroMemory( &startup, sizeof(startup) ); startup.cb = sizeof(startup); startup.cb = sizeof(startup); startup.hStdInput = GetStdHandle( STD_INPUT_HANDLE ); startup.hStdInput = GetStdHandle( STD_INPUT_HANDLE ); Loading