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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 static bool selinux; | 292 static bool selinux; |
293 static bool selinux_valid = false; | 293 static bool selinux_valid = false; |
294 | 294 |
295 if (!selinux_valid) { | 295 if (!selinux_valid) { |
296 selinux = access("/selinux", X_OK) == 0; | 296 selinux = access("/selinux", X_OK) == 0; |
297 selinux_valid = true; | 297 selinux_valid = true; |
298 } | 298 } |
299 | 299 |
300 if (using_suid_sandbox_ && !selinux) { | 300 if (using_suid_sandbox_ && !selinux) { |
301 base::ProcessHandle sandbox_helper_process; | |
302 std::vector<std::string> adj_oom_score_cmdline; | 301 std::vector<std::string> adj_oom_score_cmdline; |
303 | |
304 adj_oom_score_cmdline.push_back(sandbox_binary_); | 302 adj_oom_score_cmdline.push_back(sandbox_binary_); |
305 adj_oom_score_cmdline.push_back(base::kAdjustOOMScoreSwitch); | 303 adj_oom_score_cmdline.push_back(base::kAdjustOOMScoreSwitch); |
306 adj_oom_score_cmdline.push_back(base::Int64ToString(pid)); | 304 adj_oom_score_cmdline.push_back(base::Int64ToString(pid)); |
307 adj_oom_score_cmdline.push_back(base::IntToString(score)); | 305 adj_oom_score_cmdline.push_back(base::IntToString(score)); |
308 CommandLine adj_oom_score_cmd(adj_oom_score_cmdline); | 306 |
309 if (base::LaunchApp(adj_oom_score_cmd, false, true, | 307 base::ProcessHandle sandbox_helper_process; |
310 &sandbox_helper_process)) { | 308 base::LaunchOptions options; |
| 309 options.process_handle = &sandbox_helper_process; |
| 310 if (base::LaunchProcess(adj_oom_score_cmdline, options)) |
311 ProcessWatcher::EnsureProcessGetsReaped(sandbox_helper_process); | 311 ProcessWatcher::EnsureProcessGetsReaped(sandbox_helper_process); |
312 } | |
313 } else if (!using_suid_sandbox_) { | 312 } else if (!using_suid_sandbox_) { |
314 if (!base::AdjustOOMScore(pid, score)) | 313 if (!base::AdjustOOMScore(pid, score)) |
315 PLOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid; | 314 PLOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid; |
316 } | 315 } |
317 } | 316 } |
318 | 317 |
319 void ZygoteHost::EnsureProcessTerminated(pid_t process) { | 318 void ZygoteHost::EnsureProcessTerminated(pid_t process) { |
320 DCHECK(init_); | 319 DCHECK(init_); |
321 Pickle pickle; | 320 Pickle pickle; |
322 | 321 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { | 364 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { |
366 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; | 365 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; |
367 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 366 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
368 } | 367 } |
369 | 368 |
370 if (exit_code) | 369 if (exit_code) |
371 *exit_code = tmp_exit_code; | 370 *exit_code = tmp_exit_code; |
372 | 371 |
373 return static_cast<base::TerminationStatus>(status); | 372 return static_cast<base::TerminationStatus>(status); |
374 } | 373 } |
OLD | NEW |