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

Side by Side Diff: base/process/launch_fuchsia.cc

Issue 2950153002: Improve process launch handle sharing API. (Closed)
Patch Set: Fix Created 3 years, 5 months 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
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698