Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Unified Diff: test/win/child_launcher.cc

Issue 1355503005: win: Make reading CrashpadInfo work across bitness (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/win/child_launcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/win/child_launcher.cc
diff --git a/test/win/child_launcher.cc b/test/win/child_launcher.cc
index cc95255c58d59c9393e7be72412e7794717b4fae..2b82e057f6e43f4649785d5a764b1f54815bb184 100644
--- a/test/win/child_launcher.cc
+++ b/test/win/child_launcher.cc
@@ -25,12 +25,13 @@ ChildLauncher::ChildLauncher(const std::wstring& executable,
command_line_(command_line),
process_handle_(),
main_thread_handle_(),
- stdout_read_handle_() {
+ stdout_read_handle_(),
+ stdin_write_handle_() {
}
ChildLauncher::~ChildLauncher() {
- EXPECT_EQ(WAIT_OBJECT_0,
- WaitForSingleObject(process_handle_.get(), INFINITE));
+ if (process_handle_.is_valid())
+ WaitForExit();
}
void ChildLauncher::Start() {
@@ -38,10 +39,11 @@ void ChildLauncher::Start() {
ASSERT_FALSE(main_thread_handle_.is_valid());
ASSERT_FALSE(stdout_read_handle_.is_valid());
- // Create a pipe for the stdout of the child.
+ // Create pipes for the stdin/stdout of the child.
SECURITY_ATTRIBUTES security_attributes = {0};
security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
security_attributes.bInheritHandle = true;
+
HANDLE stdout_read;
HANDLE stdout_write;
ASSERT_TRUE(CreatePipe(&stdout_read, &stdout_write, &security_attributes, 0));
@@ -50,9 +52,17 @@ void ChildLauncher::Start() {
ASSERT_TRUE(
SetHandleInformation(stdout_read_handle_.get(), HANDLE_FLAG_INHERIT, 0));
+ HANDLE stdin_read;
+ HANDLE stdin_write;
+ ASSERT_TRUE(CreatePipe(&stdin_read, &stdin_write, &security_attributes, 0));
+ stdin_write_handle_.reset(stdin_write);
+ ScopedFileHANDLE read_handle(stdin_read);
+ ASSERT_TRUE(
+ SetHandleInformation(stdin_write_handle_.get(), HANDLE_FLAG_INHERIT, 0));
+
STARTUPINFO startup_info = {0};
startup_info.cb = sizeof(startup_info);
- startup_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+ startup_info.hStdInput = read_handle.get();
startup_info.hStdOutput = write_handle.get();
startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
startup_info.dwFlags = STARTF_USESTDHANDLES;
@@ -76,6 +86,16 @@ void ChildLauncher::Start() {
process_handle_.reset(process_information.hProcess);
}
+DWORD ChildLauncher::WaitForExit() {
+ EXPECT_TRUE(process_handle_.is_valid());
+ EXPECT_EQ(WAIT_OBJECT_0,
+ WaitForSingleObject(process_handle_.get(), INFINITE));
+ DWORD exit_code = 0;
+ EXPECT_TRUE(GetExitCodeProcess(process_handle_.get(), &exit_code));
+ process_handle_.reset();
+ return exit_code;
+}
+
// Ref: http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
void AppendCommandLineArgument(const std::wstring& argument,
std::wstring* command_line) {
« no previous file with comments | « test/win/child_launcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698