| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/process/launch.h" | 5 #include "base/process/launch.h" |
| 6 | 6 |
| 7 #include <launchpad/launchpad.h> | 7 #include <launchpad/launchpad.h> |
| 8 #include <magenta/process.h> | 8 #include <magenta/process.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (!environ_modifications.empty()) | 111 if (!environ_modifications.empty()) |
| 112 new_environ = AlterEnvironment(old_environ, environ_modifications); | 112 new_environ = AlterEnvironment(old_environ, environ_modifications); |
| 113 | 113 |
| 114 if (!environ_modifications.empty() || options.clear_environ) | 114 if (!environ_modifications.empty() || options.clear_environ) |
| 115 launchpad_set_environ(lp, new_environ.get()); | 115 launchpad_set_environ(lp, new_environ.get()); |
| 116 else | 116 else |
| 117 to_clone |= LP_CLONE_ENVIRON; | 117 to_clone |= LP_CLONE_ENVIRON; |
| 118 | 118 |
| 119 if (!options.fds_to_remap) | 119 if (options.fds_to_remap.empty()) |
| 120 to_clone |= LP_CLONE_MXIO_STDIO; | 120 to_clone |= LP_CLONE_MXIO_STDIO; |
| 121 launchpad_clone(lp, to_clone); | 121 launchpad_clone(lp, to_clone); |
| 122 | 122 |
| 123 if (options.fds_to_remap) { | 123 for (const auto& src_target : options.fds_to_remap) |
| 124 for (const auto& src_target : *options.fds_to_remap) { | 124 launchpad_clone_fd(lp, src_target.first, src_target.second); |
| 125 launchpad_clone_fd(lp, src_target.first, src_target.second); | |
| 126 } | |
| 127 } | |
| 128 | 125 |
| 129 mx_handle_t proc; | 126 mx_handle_t proc; |
| 130 const char* errmsg; | 127 const char* errmsg; |
| 131 mx_status_t status = launchpad_go(lp, &proc, &errmsg); | 128 mx_status_t status = launchpad_go(lp, &proc, &errmsg); |
| 132 if (status != MX_OK) { | 129 if (status != MX_OK) { |
| 133 LOG(ERROR) << "launchpad_go failed: " << errmsg << ", status=" << status; | 130 LOG(ERROR) << "launchpad_go failed: " << errmsg << ", status=" << status; |
| 134 return Process(); | 131 return Process(); |
| 135 } | 132 } |
| 136 | 133 |
| 137 return Process(proc); | 134 return Process(proc); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 159 } | 156 } |
| 160 | 157 |
| 161 bool GetAppOutputWithExitCode(const CommandLine& cl, | 158 bool GetAppOutputWithExitCode(const CommandLine& cl, |
| 162 std::string* output, | 159 std::string* output, |
| 163 int* exit_code) { | 160 int* exit_code) { |
| 164 bool result = GetAppOutputInternal(cl.argv(), false, output, exit_code); | 161 bool result = GetAppOutputInternal(cl.argv(), false, output, exit_code); |
| 165 return result && *exit_code == EXIT_SUCCESS; | 162 return result && *exit_code == EXIT_SUCCESS; |
| 166 } | 163 } |
| 167 | 164 |
| 168 } // namespace base | 165 } // namespace base |
| OLD | NEW |