| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/process_proxy/process_proxy.h" | 5 #include "chromeos/process_proxy/process_proxy.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <sys/ioctl.h> | 9 #include <sys/ioctl.h> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/posix/eintr_wrapper.h" | 15 #include "base/posix/eintr_wrapper.h" |
| 16 #include "base/process/kill.h" | 16 #include "base/process/kill.h" |
| 17 #include "base/process/launch.h" | 17 #include "base/process/launch.h" |
| 18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "chromeos/process_proxy/process_output_watcher.h" | 19 #include "chromeos/process_proxy/process_output_watcher.h" |
| 20 #include "third_party/cros_system_api/switches/chrome_switches.h" | 20 #include "third_party/cros_system_api/switches/chrome_switches.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 namespace chromeos { | 38 namespace chromeos { |
| 39 | 39 |
| 40 ProcessProxy::ProcessProxy(): process_launched_(false), | 40 ProcessProxy::ProcessProxy(): process_launched_(false), |
| 41 callback_set_(false), | 41 callback_set_(false), |
| 42 watcher_started_(false) { | 42 watcher_started_(false) { |
| 43 // Set pipes to initial, invalid value so we can easily know if a pipe was | 43 // Set pipes to initial, invalid value so we can easily know if a pipe was |
| 44 // opened by us. | 44 // opened by us. |
| 45 ClearAllFdPairs(); | 45 ClearAllFdPairs(); |
| 46 }; | 46 } |
| 47 | 47 |
| 48 bool ProcessProxy::Open(const std::string& command, pid_t* pid) { | 48 bool ProcessProxy::Open(const std::string& command, pid_t* pid) { |
| 49 if (process_launched_) | 49 if (process_launched_) |
| 50 return false; | 50 return false; |
| 51 | 51 |
| 52 if (!CreatePseudoTerminalPair(pt_pair_)) { | 52 if (!CreatePseudoTerminalPair(pt_pair_)) { |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 | 55 |
| 56 process_launched_ = LaunchProcess(command, pt_pair_[PT_SLAVE_FD], &pid_); | 56 process_launched_ = LaunchProcess(command, pt_pair_[PT_SLAVE_FD], &pid_); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 ClearFdPair(pt_pair_); | 259 ClearFdPair(pt_pair_); |
| 260 ClearFdPair(shutdown_pipe_); | 260 ClearFdPair(shutdown_pipe_); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void ProcessProxy::ClearFdPair(int* pipe) { | 263 void ProcessProxy::ClearFdPair(int* pipe) { |
| 264 pipe[PIPE_END_READ] = kInvalidFd; | 264 pipe[PIPE_END_READ] = kInvalidFd; |
| 265 pipe[PIPE_END_WRITE] = kInvalidFd; | 265 pipe[PIPE_END_WRITE] = kInvalidFd; |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace chromeos | 268 } // namespace chromeos |
| OLD | NEW |