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 } |
62 | 63 |
63 ZygoteHost::~ZygoteHost() { | 64 ZygoteHost::~ZygoteHost() { |
64 if (init_) | 65 if (init_) |
65 close(control_fd_); | 66 close(control_fd_); |
66 } | 67 } |
67 | 68 |
68 // static | 69 // static |
69 ZygoteHost* ZygoteHost::GetInstance() { | 70 ZygoteHost* ZygoteHost::GetInstance() { |
70 return Singleton<ZygoteHost>::get(); | 71 return Singleton<ZygoteHost>::get(); |
71 } | 72 } |
(...skipping 30 matching lines...) Expand all Loading... |
102 // Should this list be obtained from browser_render_process_host.cc? | 103 // Should this list be obtained from browser_render_process_host.cc? |
103 static const char* kForwardSwitches[] = { | 104 static const char* kForwardSwitches[] = { |
104 switches::kAllowSandboxDebugging, | 105 switches::kAllowSandboxDebugging, |
105 switches::kLoggingLevel, | 106 switches::kLoggingLevel, |
106 switches::kEnableLogging, // Support, e.g., --enable-logging=stderr. | 107 switches::kEnableLogging, // Support, e.g., --enable-logging=stderr. |
107 switches::kV, | 108 switches::kV, |
108 switches::kVModule, | 109 switches::kVModule, |
109 switches::kRegisterPepperPlugins, | 110 switches::kRegisterPepperPlugins, |
110 switches::kDisableSeccompSandbox, | 111 switches::kDisableSeccompSandbox, |
111 switches::kEnableSeccompSandbox, | 112 switches::kEnableSeccompSandbox, |
112 switches::kNaClLinuxHelper, | |
113 }; | 113 }; |
114 cmd_line.CopySwitchesFrom(browser_command_line, kForwardSwitches, | 114 cmd_line.CopySwitchesFrom(browser_command_line, kForwardSwitches, |
115 arraysize(kForwardSwitches)); | 115 arraysize(kForwardSwitches)); |
116 | 116 |
117 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 117 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
118 &cmd_line, -1); | 118 &cmd_line, -1); |
119 | 119 |
120 sandbox_binary_ = sandbox_cmd.c_str(); | 120 sandbox_binary_ = sandbox_cmd.c_str(); |
121 struct stat st; | 121 struct stat st; |
122 | 122 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 sizeof(sandbox_status_))) != | 214 sizeof(sandbox_status_))) != |
215 sizeof(sandbox_status_)) { | 215 sizeof(sandbox_status_)) { |
216 return -1; | 216 return -1; |
217 } | 217 } |
218 have_read_sandbox_status_word_ = true; | 218 have_read_sandbox_status_word_ = true; |
219 } | 219 } |
220 | 220 |
221 return HANDLE_EINTR(read(control_fd_, buf, buf_len)); | 221 return HANDLE_EINTR(read(control_fd_, buf, buf_len)); |
222 } | 222 } |
223 | 223 |
224 pid_t ZygoteHost::ForkRequest( | 224 pid_t ZygoteHost::ForkRenderer( |
225 const std::vector<std::string>& argv, | 225 const std::vector<std::string>& argv, |
226 const base::GlobalDescriptors::Mapping& mapping, | 226 const base::GlobalDescriptors::Mapping& mapping) { |
227 const std::string& process_type) { | |
228 DCHECK(init_); | 227 DCHECK(init_); |
229 Pickle pickle; | 228 Pickle pickle; |
230 | 229 |
231 pickle.WriteInt(kCmdFork); | 230 pickle.WriteInt(kCmdFork); |
232 pickle.WriteString(process_type); | |
233 pickle.WriteInt(argv.size()); | 231 pickle.WriteInt(argv.size()); |
234 for (std::vector<std::string>::const_iterator | 232 for (std::vector<std::string>::const_iterator |
235 i = argv.begin(); i != argv.end(); ++i) | 233 i = argv.begin(); i != argv.end(); ++i) |
236 pickle.WriteString(*i); | 234 pickle.WriteString(*i); |
237 | 235 |
238 pickle.WriteInt(mapping.size()); | 236 pickle.WriteInt(mapping.size()); |
239 | 237 |
240 std::vector<int> fds; | 238 std::vector<int> fds; |
241 for (base::GlobalDescriptors::Mapping::const_iterator | 239 for (base::GlobalDescriptors::Mapping::const_iterator |
242 i = mapping.begin(); i != mapping.end(); ++i) { | 240 i = mapping.begin(); i != mapping.end(); ++i) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { | 362 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { |
365 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; | 363 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; |
366 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 364 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
367 } | 365 } |
368 | 366 |
369 if (exit_code) | 367 if (exit_code) |
370 *exit_code = tmp_exit_code; | 368 *exit_code = tmp_exit_code; |
371 | 369 |
372 return static_cast<base::TerminationStatus>(status); | 370 return static_cast<base::TerminationStatus>(status); |
373 } | 371 } |
OLD | NEW |