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 "components/nacl/zygote/nacl_fork_delegate_linux.h" | 5 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 if (status_ == kNaClHelperSuccess) { | 245 if (status_ == kNaClHelperSuccess) { |
246 if (IGNORE_EINTR(close(fd_)) != 0) | 246 if (IGNORE_EINTR(close(fd_)) != 0) |
247 LOG(ERROR) << "close(fd_) failed"; | 247 LOG(ERROR) << "close(fd_) failed"; |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 bool NaClForkDelegate::CanHelp(const std::string& process_type, | 251 bool NaClForkDelegate::CanHelp(const std::string& process_type, |
252 std::string* uma_name, | 252 std::string* uma_name, |
253 int* uma_sample, | 253 int* uma_sample, |
254 int* uma_boundary_value) { | 254 int* uma_boundary_value) { |
255 if (process_type != switches::kNaClLoaderProcess) | 255 if (process_type != switches::kNaClLoaderProcess && |
| 256 process_type != switches::kNaClLoaderNonSfiProcess) |
256 return false; | 257 return false; |
257 *uma_name = "NaCl.Client.Helper.StateOnFork"; | 258 *uma_name = "NaCl.Client.Helper.StateOnFork"; |
258 *uma_sample = status_; | 259 *uma_sample = status_; |
259 *uma_boundary_value = kNaClHelperStatusBoundary; | 260 *uma_boundary_value = kNaClHelperStatusBoundary; |
260 return true; | 261 return true; |
261 } | 262 } |
262 | 263 |
263 pid_t NaClForkDelegate::Fork(const std::vector<int>& fds) { | 264 pid_t NaClForkDelegate::Fork(const std::string& process_type, |
| 265 const std::vector<int>& fds) { |
264 VLOG(1) << "NaClForkDelegate::Fork"; | 266 VLOG(1) << "NaClForkDelegate::Fork"; |
265 | 267 |
266 DCHECK(fds.size() == kNumPassedFDs); | 268 DCHECK(fds.size() == kNumPassedFDs); |
267 | 269 |
268 if (status_ != kNaClHelperSuccess) { | 270 if (status_ != kNaClHelperSuccess) { |
269 LOG(ERROR) << "Cannot launch NaCl process: nacl_helper failed to start"; | 271 LOG(ERROR) << "Cannot launch NaCl process: nacl_helper failed to start"; |
270 return -1; | 272 return -1; |
271 } | 273 } |
272 | 274 |
273 // First, send a remote fork request. | 275 // First, send a remote fork request. |
274 Pickle write_pickle; | 276 Pickle write_pickle; |
275 write_pickle.WriteInt(nacl::kNaClForkRequest); | 277 write_pickle.WriteInt(nacl::kNaClForkRequest); |
| 278 // TODO(hamaji): When we split the helper binary for non-SFI mode |
| 279 // from nacl_helper, stop sending this information. |
| 280 const bool uses_nonsfi_mode = |
| 281 process_type == switches::kNaClLoaderNonSfiProcess; |
| 282 write_pickle.WriteBool(uses_nonsfi_mode); |
276 | 283 |
277 char reply_buf[kNaClMaxIPCMessageLength]; | 284 char reply_buf[kNaClMaxIPCMessageLength]; |
278 ssize_t reply_size = 0; | 285 ssize_t reply_size = 0; |
279 bool got_reply = | 286 bool got_reply = |
280 SendIPCRequestAndReadReply(fd_, fds, write_pickle, | 287 SendIPCRequestAndReadReply(fd_, fds, write_pickle, |
281 reply_buf, sizeof(reply_buf), &reply_size); | 288 reply_buf, sizeof(reply_buf), &reply_size); |
282 if (!got_reply) { | 289 if (!got_reply) { |
283 LOG(ERROR) << "Could not perform remote fork."; | 290 LOG(ERROR) << "Could not perform remote fork."; |
284 return -1; | 291 return -1; |
285 } | 292 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 int remote_exit_code; | 349 int remote_exit_code; |
343 if (!iter.ReadInt(&remote_exit_code)) { | 350 if (!iter.ReadInt(&remote_exit_code)) { |
344 LOG(ERROR) << "GetTerminationStatus: pickle failed"; | 351 LOG(ERROR) << "GetTerminationStatus: pickle failed"; |
345 return false; | 352 return false; |
346 } | 353 } |
347 | 354 |
348 *status = static_cast<base::TerminationStatus>(termination_status); | 355 *status = static_cast<base::TerminationStatus>(termination_status); |
349 *exit_code = remote_exit_code; | 356 *exit_code = remote_exit_code; |
350 return true; | 357 return true; |
351 } | 358 } |
OLD | NEW |