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

Side by Side Diff: tools/gn/function_exec_script.cc

Issue 71013004: Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix delegate_execute for google_chrome_build Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/win/src/target_process.cc ('k') | win8/delegate_execute/chrome_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/process/kill.h" 8 #include "base/process/kill.h"
9 #include "base/process/launch.h" 9 #include "base/process/launch.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 NOTREACHED() << "Failed to disabled pipe inheritance"; 78 NOTREACHED() << "Failed to disabled pipe inheritance";
79 return false; 79 return false;
80 } 80 }
81 if (!SetHandleInformation(err_read, HANDLE_FLAG_INHERIT, 0)) { 81 if (!SetHandleInformation(err_read, HANDLE_FLAG_INHERIT, 0)) {
82 NOTREACHED() << "Failed to disabled pipe inheritance"; 82 NOTREACHED() << "Failed to disabled pipe inheritance";
83 return false; 83 return false;
84 } 84 }
85 85
86 base::FilePath::StringType cmdline_str(cmdline.GetCommandLineString()); 86 base::FilePath::StringType cmdline_str(cmdline.GetCommandLineString());
87 87
88 base::win::ScopedProcessInformation proc_info; 88 STARTUPINFO start_info = {};
89 STARTUPINFO start_info = { 0 };
90 89
91 start_info.cb = sizeof(STARTUPINFO); 90 start_info.cb = sizeof(STARTUPINFO);
92 start_info.hStdOutput = out_write; 91 start_info.hStdOutput = out_write;
93 // Keep the normal stdin. 92 // Keep the normal stdin.
94 start_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE); 93 start_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
95 // FIXME(brettw) set stderr here when we actually read it below. 94 // FIXME(brettw) set stderr here when we actually read it below.
96 //start_info.hStdError = err_write; 95 //start_info.hStdError = err_write;
97 start_info.hStdError = GetStdHandle(STD_ERROR_HANDLE); 96 start_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
98 start_info.dwFlags |= STARTF_USESTDHANDLES; 97 start_info.dwFlags |= STARTF_USESTDHANDLES;
99 98
100 // Create the child process. 99 // Create the child process.
100 PROCESS_INFORMATION temp_process_info = {};
101 if (!CreateProcess(NULL, 101 if (!CreateProcess(NULL,
102 &cmdline_str[0], 102 &cmdline_str[0],
103 NULL, NULL, 103 NULL, NULL,
104 TRUE, // Handles are inherited. 104 TRUE, // Handles are inherited.
105 0, NULL, 105 0, NULL,
106 startup_dir.value().c_str(), 106 startup_dir.value().c_str(),
107 &start_info, proc_info.Receive())) { 107 &start_info, &temp_process_info)) {
108 return false; 108 return false;
109 } 109 }
110 base::win::ScopedProcessInformation proc_info(temp_process_info);
110 111
111 // Close our writing end of pipes now. Otherwise later read would not be able 112 // Close our writing end of pipes now. Otherwise later read would not be able
112 // to detect end of child's output. 113 // to detect end of child's output.
113 scoped_out_write.Close(); 114 scoped_out_write.Close();
114 scoped_err_write.Close(); 115 scoped_err_write.Close();
115 116
116 // Read output from the child process's pipe for STDOUT 117 // Read output from the child process's pipe for STDOUT
117 const int kBufferSize = 1024; 118 const int kBufferSize = 1024;
118 char buffer[kBufferSize]; 119 char buffer[kBufferSize];
119 120
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 msg += "."; 389 msg += ".";
389 *err = Err(function->function(), "Script returned non-zero exit code.", 390 *err = Err(function->function(), "Script returned non-zero exit code.",
390 msg); 391 msg);
391 return Value(); 392 return Value();
392 } 393 }
393 394
394 return ConvertInputToValue(output, function, args[2], err); 395 return ConvertInputToValue(output, function, args[2], err);
395 } 396 }
396 397
397 } // namespace functions 398 } // namespace functions
OLDNEW
« no previous file with comments | « sandbox/win/src/target_process.cc ('k') | win8/delegate_execute/chrome_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698