| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file_util.h" | 6 #include "base/files/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 | 10 |
| 11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
| 12 #include <windows.h> | 12 #include <windows.h> |
| 13 | 13 |
| 14 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
| 15 #include "base/win/scoped_process_information.h" | 15 #include "base/win/scoped_process_information.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 #if defined(OS_POSIX) | 18 #if defined(OS_POSIX) |
| 19 #include <fcntl.h> | 19 #include <fcntl.h> |
| 20 #include <unistd.h> | 20 #include <unistd.h> |
| 21 | 21 |
| 22 #include "base/posix/eintr_wrapper.h" | 22 #include "base/posix/eintr_wrapper.h" |
| 23 #include "base/posix/file_descriptor_shuffle.h" | 23 #include "base/posix/file_descriptor_shuffle.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 namespace internal { | 26 namespace internal { |
| 27 | 27 |
| 28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 29 bool ExecProcess(const CommandLine& cmdline, | 29 bool ExecProcess(const base::CommandLine& cmdline, |
| 30 const base::FilePath& startup_dir, | 30 const base::FilePath& startup_dir, |
| 31 std::string* std_out, | 31 std::string* std_out, |
| 32 std::string* std_err, | 32 std::string* std_err, |
| 33 int* exit_code) { | 33 int* exit_code) { |
| 34 SECURITY_ATTRIBUTES sa_attr; | 34 SECURITY_ATTRIBUTES sa_attr; |
| 35 // Set the bInheritHandle flag so pipe handles are inherited. | 35 // Set the bInheritHandle flag so pipe handles are inherited. |
| 36 sa_attr.nLength = sizeof(SECURITY_ATTRIBUTES); | 36 sa_attr.nLength = sizeof(SECURITY_ATTRIBUTES); |
| 37 sa_attr.bInheritHandle = TRUE; | 37 sa_attr.bInheritHandle = TRUE; |
| 38 sa_attr.lpSecurityDescriptor = NULL; | 38 sa_attr.lpSecurityDescriptor = NULL; |
| 39 | 39 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 int bytes_read = HANDLE_EINTR(read(fd, buffer, sizeof(buffer))); | 131 int bytes_read = HANDLE_EINTR(read(fd, buffer, sizeof(buffer))); |
| 132 if (bytes_read == -1) { | 132 if (bytes_read == -1) { |
| 133 return errno == EAGAIN || errno == EWOULDBLOCK; | 133 return errno == EAGAIN || errno == EWOULDBLOCK; |
| 134 } else if (bytes_read <= 0) { | 134 } else if (bytes_read <= 0) { |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 output->append(buffer, bytes_read); | 137 output->append(buffer, bytes_read); |
| 138 return true; | 138 return true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool ExecProcess(const CommandLine& cmdline, | 141 bool ExecProcess(const base::CommandLine& cmdline, |
| 142 const base::FilePath& startup_dir, | 142 const base::FilePath& startup_dir, |
| 143 std::string* std_out, | 143 std::string* std_out, |
| 144 std::string* std_err, | 144 std::string* std_err, |
| 145 int* exit_code) { | 145 int* exit_code) { |
| 146 *exit_code = EXIT_FAILURE; | 146 *exit_code = EXIT_FAILURE; |
| 147 | 147 |
| 148 std::vector<std::string> argv = cmdline.argv(); | 148 std::vector<std::string> argv = cmdline.argv(); |
| 149 | 149 |
| 150 int out_fd[2], err_fd[2]; | 150 int out_fd[2], err_fd[2]; |
| 151 pid_t pid; | 151 pid_t pid; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return base::WaitForExitCode(pid, exit_code); | 240 return base::WaitForExitCode(pid, exit_code); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 return false; | 244 return false; |
| 245 } | 245 } |
| 246 #endif | 246 #endif |
| 247 | 247 |
| 248 } // namespace internal | 248 } // namespace internal |
| 249 | 249 |
| OLD | NEW |