OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/zygote_host_linux.h" | 5 #include "content/browser/zygote_host_linux.h" |
6 | 6 |
7 #include <sys/socket.h> | 7 #include <sys/socket.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 free(saved_envvar); | 51 free(saved_envvar); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 ZygoteHost::ZygoteHost() | 55 ZygoteHost::ZygoteHost() |
56 : control_fd_(-1), | 56 : control_fd_(-1), |
57 pid_(-1), | 57 pid_(-1), |
58 init_(false), | 58 init_(false), |
59 using_suid_sandbox_(false), | 59 using_suid_sandbox_(false), |
60 have_read_sandbox_status_word_(false), | 60 have_read_sandbox_status_word_(false), |
61 sandbox_status_(0) { | 61 sandbox_status_(0) {} |
62 } | |
63 | 62 |
64 ZygoteHost::~ZygoteHost() { | 63 ZygoteHost::~ZygoteHost() { |
65 if (init_) | 64 if (init_) |
66 close(control_fd_); | 65 close(control_fd_); |
67 } | 66 } |
68 | 67 |
69 // static | 68 // static |
70 ZygoteHost* ZygoteHost::GetInstance() { | 69 ZygoteHost* ZygoteHost::GetInstance() { |
71 return Singleton<ZygoteHost>::get(); | 70 return Singleton<ZygoteHost>::get(); |
72 } | 71 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 sizeof(sandbox_status_))) != | 213 sizeof(sandbox_status_))) != |
215 sizeof(sandbox_status_)) { | 214 sizeof(sandbox_status_)) { |
216 return -1; | 215 return -1; |
217 } | 216 } |
218 have_read_sandbox_status_word_ = true; | 217 have_read_sandbox_status_word_ = true; |
219 } | 218 } |
220 | 219 |
221 return HANDLE_EINTR(read(control_fd_, buf, buf_len)); | 220 return HANDLE_EINTR(read(control_fd_, buf, buf_len)); |
222 } | 221 } |
223 | 222 |
224 pid_t ZygoteHost::ForkRenderer( | 223 pid_t ZygoteHost::ForkRequest( |
225 const std::vector<std::string>& argv, | 224 const std::vector<std::string>& argv, |
226 const base::GlobalDescriptors::Mapping& mapping) { | 225 const base::GlobalDescriptors::Mapping& mapping, |
| 226 const std::string& process_type) { |
227 DCHECK(init_); | 227 DCHECK(init_); |
228 Pickle pickle; | 228 Pickle pickle; |
229 | 229 |
230 pickle.WriteInt(kCmdFork); | 230 pickle.WriteInt(kCmdFork); |
| 231 pickle.WriteString(process_type); |
231 pickle.WriteInt(argv.size()); | 232 pickle.WriteInt(argv.size()); |
232 for (std::vector<std::string>::const_iterator | 233 for (std::vector<std::string>::const_iterator |
233 i = argv.begin(); i != argv.end(); ++i) | 234 i = argv.begin(); i != argv.end(); ++i) |
234 pickle.WriteString(*i); | 235 pickle.WriteString(*i); |
235 | 236 |
236 pickle.WriteInt(mapping.size()); | 237 pickle.WriteInt(mapping.size()); |
237 | 238 |
238 std::vector<int> fds; | 239 std::vector<int> fds; |
239 for (base::GlobalDescriptors::Mapping::const_iterator | 240 for (base::GlobalDescriptors::Mapping::const_iterator |
240 i = mapping.begin(); i != mapping.end(); ++i) { | 241 i = mapping.begin(); i != mapping.end(); ++i) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { | 363 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { |
363 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; | 364 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; |
364 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 365 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
365 } | 366 } |
366 | 367 |
367 if (exit_code) | 368 if (exit_code) |
368 *exit_code = tmp_exit_code; | 369 *exit_code = tmp_exit_code; |
369 | 370 |
370 return static_cast<base::TerminationStatus>(status); | 371 return static_cast<base::TerminationStatus>(status); |
371 } | 372 } |
OLD | NEW |