| Index: base/test/launcher/test_launcher.cc
|
| diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
|
| index 2f22d32d50a4dba63b902aa4006e94a22db08071..1c945d3606d1bd6e76674ebced4660a35927d5fe 100644
|
| --- a/base/test/launcher/test_launcher.cc
|
| +++ b/base/test/launcher/test_launcher.cc
|
| @@ -309,7 +309,26 @@ int LaunchChildTestProcessWithOptions(
|
| // in the set.
|
| AutoLock lock(g_live_processes_lock.Get());
|
|
|
| +#if defined(OS_WIN)
|
| + // Allow the handle used to capture stdio and stdout to be inherited by the
|
| + // child. Note that this is done under g_live_processes_lock to ensure that
|
| + // only the desired child receives the handle.
|
| + if (new_options.stdout_handle) {
|
| + ::SetHandleInformation(new_options.stdout_handle, HANDLE_FLAG_INHERIT,
|
| + HANDLE_FLAG_INHERIT);
|
| + }
|
| +#endif
|
| +
|
| process = LaunchProcess(command_line, new_options);
|
| +
|
| +#if defined(OS_WIN)
|
| + // Revoke inheritance so that the handle isn't leaked into other children.
|
| + // Note that this is done under g_live_processes_lock to ensure that only
|
| + // the desired child receives the handle.
|
| + if (new_options.stdout_handle)
|
| + ::SetHandleInformation(new_options.stdout_handle, HANDLE_FLAG_INHERIT, 0);
|
| +#endif
|
| +
|
| if (!process.IsValid())
|
| return -1;
|
|
|
| @@ -382,19 +401,9 @@ void DoLaunchChildTestProcess(
|
| win::ScopedHandle handle;
|
|
|
| if (redirect_stdio) {
|
| - // Make the file handle inheritable by the child.
|
| - SECURITY_ATTRIBUTES sa_attr;
|
| - sa_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
| - sa_attr.lpSecurityDescriptor = NULL;
|
| - sa_attr.bInheritHandle = TRUE;
|
| -
|
| - handle.Set(CreateFile(output_file.value().c_str(),
|
| - GENERIC_WRITE,
|
| - FILE_SHARE_READ | FILE_SHARE_DELETE,
|
| - &sa_attr,
|
| - OPEN_EXISTING,
|
| - FILE_ATTRIBUTE_TEMPORARY,
|
| - NULL));
|
| + handle.Set(CreateFile(output_file.value().c_str(), GENERIC_WRITE,
|
| + FILE_SHARE_READ | FILE_SHARE_DELETE, nullptr,
|
| + OPEN_EXISTING, FILE_ATTRIBUTE_TEMPORARY, NULL));
|
| CHECK(handle.IsValid());
|
| options.inherit_handles = true;
|
| options.stdin_handle = INVALID_HANDLE_VALUE;
|
|
|