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

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

Issue 90963002: Revert of Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/command_execute_impl.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 STARTUPINFO start_info = {}; 88 base::win::ScopedProcessInformation proc_info;
89 STARTUPINFO start_info = { 0 };
89 90
90 start_info.cb = sizeof(STARTUPINFO); 91 start_info.cb = sizeof(STARTUPINFO);
91 start_info.hStdOutput = out_write; 92 start_info.hStdOutput = out_write;
92 // Keep the normal stdin. 93 // Keep the normal stdin.
93 start_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE); 94 start_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
94 // FIXME(brettw) set stderr here when we actually read it below. 95 // FIXME(brettw) set stderr here when we actually read it below.
95 //start_info.hStdError = err_write; 96 //start_info.hStdError = err_write;
96 start_info.hStdError = GetStdHandle(STD_ERROR_HANDLE); 97 start_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
97 start_info.dwFlags |= STARTF_USESTDHANDLES; 98 start_info.dwFlags |= STARTF_USESTDHANDLES;
98 99
99 // Create the child process. 100 // 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, &temp_process_info)) { 107 &start_info, proc_info.Receive())) {
108 return false; 108 return false;
109 } 109 }
110 base::win::ScopedProcessInformation proc_info(temp_process_info);
111 110
112 // Close our writing end of pipes now. Otherwise later read would not be able 111 // Close our writing end of pipes now. Otherwise later read would not be able
113 // to detect end of child's output. 112 // to detect end of child's output.
114 scoped_out_write.Close(); 113 scoped_out_write.Close();
115 scoped_err_write.Close(); 114 scoped_err_write.Close();
116 115
117 // Read output from the child process's pipe for STDOUT 116 // Read output from the child process's pipe for STDOUT
118 const int kBufferSize = 1024; 117 const int kBufferSize = 1024;
119 char buffer[kBufferSize]; 118 char buffer[kBufferSize];
120 119
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 msg += "."; 388 msg += ".";
390 *err = Err(function->function(), "Script returned non-zero exit code.", 389 *err = Err(function->function(), "Script returned non-zero exit code.",
391 msg); 390 msg);
392 return Value(); 391 return Value();
393 } 392 }
394 393
395 return ConvertInputToValue(output, function, args[2], err); 394 return ConvertInputToValue(output, function, args[2], err);
396 } 395 }
397 396
398 } // namespace functions 397 } // namespace functions
OLDNEW
« no previous file with comments | « sandbox/win/src/target_process.cc ('k') | win8/delegate_execute/command_execute_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698