OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |