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 "content/zygote/zygote_linux.h" | 5 #include "content/zygote/zygote_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <poll.h> | 9 #include <poll.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "base/posix/global_descriptors.h" | 26 #include "base/posix/global_descriptors.h" |
27 #include "base/posix/unix_domain_socket_linux.h" | 27 #include "base/posix/unix_domain_socket_linux.h" |
28 #include "base/process/kill.h" | 28 #include "base/process/kill.h" |
29 #include "base/process/launch.h" | 29 #include "base/process/launch.h" |
30 #include "base/process/process.h" | 30 #include "base/process/process.h" |
31 #include "base/process/process_handle.h" | 31 #include "base/process/process_handle.h" |
32 #include "base/time/time.h" | 32 #include "base/time/time.h" |
33 #include "base/trace_event/trace_event.h" | 33 #include "base/trace_event/trace_event.h" |
34 #include "build/build_config.h" | 34 #include "build/build_config.h" |
35 #include "content/common/sandbox_linux/sandbox_linux.h" | 35 #include "content/common/sandbox_linux/sandbox_linux.h" |
| 36 #include "content/common/set_process_title.h" |
36 #include "content/common/zygote_commands_linux.h" | 37 #include "content/common/zygote_commands_linux.h" |
37 #include "content/public/common/content_descriptors.h" | 38 #include "content/public/common/content_descriptors.h" |
38 #include "content/public/common/mojo_channel_switches.h" | 39 #include "content/public/common/mojo_channel_switches.h" |
39 #include "content/public/common/result_codes.h" | 40 #include "content/public/common/result_codes.h" |
40 #include "content/public/common/sandbox_linux.h" | 41 #include "content/public/common/sandbox_linux.h" |
41 #include "content/public/common/send_zygote_child_ping_linux.h" | 42 #include "content/public/common/send_zygote_child_ping_linux.h" |
42 #include "content/public/common/zygote_fork_delegate_linux.h" | 43 #include "content/public/common/zygote_fork_delegate_linux.h" |
43 #include "ipc/ipc_channel.h" | 44 #include "ipc/ipc_channel.h" |
44 #include "sandbox/linux/services/credentials.h" | 45 #include "sandbox/linux/services/credentials.h" |
45 #include "sandbox/linux/services/namespace_sandbox.h" | 46 #include "sandbox/linux/services/namespace_sandbox.h" |
46 #include "services/service_manager/embedder/set_process_title.h" | |
47 | 47 |
48 // See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote
.md | 48 // See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote
.md |
49 | 49 |
50 namespace content { | 50 namespace content { |
51 | 51 |
52 namespace { | 52 namespace { |
53 | 53 |
54 // NOP function. See below where this handler is installed. | 54 // NOP function. See below where this handler is installed. |
55 void SIGCHLDHandler(int signal) { | 55 void SIGCHLDHandler(int signal) { |
56 } | 56 } |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 base::GlobalDescriptors::GetInstance()->Reset(mapping); | 614 base::GlobalDescriptors::GetInstance()->Reset(mapping); |
615 | 615 |
616 // Reset the process-wide command line to our new command line. | 616 // Reset the process-wide command line to our new command line. |
617 base::CommandLine::Reset(); | 617 base::CommandLine::Reset(); |
618 base::CommandLine::Init(0, NULL); | 618 base::CommandLine::Init(0, NULL); |
619 base::CommandLine::ForCurrentProcess()->InitFromArgv(args); | 619 base::CommandLine::ForCurrentProcess()->InitFromArgv(args); |
620 | 620 |
621 // Update the process title. The argv was already cached by the call to | 621 // Update the process title. The argv was already cached by the call to |
622 // SetProcessTitleFromCommandLine in ChromeMain, so we can pass NULL here | 622 // SetProcessTitleFromCommandLine in ChromeMain, so we can pass NULL here |
623 // (we don't have the original argv at this point). | 623 // (we don't have the original argv at this point). |
624 service_manager::SetProcessTitleFromCommandLine(nullptr); | 624 SetProcessTitleFromCommandLine(NULL); |
625 } else if (child_pid < 0) { | 625 } else if (child_pid < 0) { |
626 LOG(ERROR) << "Zygote could not fork: process_type " << process_type | 626 LOG(ERROR) << "Zygote could not fork: process_type " << process_type |
627 << " numfds " << numfds << " child_pid " << child_pid; | 627 << " numfds " << numfds << " child_pid " << child_pid; |
628 } | 628 } |
629 return child_pid; | 629 return child_pid; |
630 } | 630 } |
631 | 631 |
632 bool Zygote::HandleForkRequest(int fd, | 632 bool Zygote::HandleForkRequest(int fd, |
633 base::PickleIterator iter, | 633 base::PickleIterator iter, |
634 std::vector<base::ScopedFD> fds) { | 634 std::vector<base::ScopedFD> fds) { |
(...skipping 27 matching lines...) Expand all Loading... |
662 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { | 662 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { |
663 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != | 663 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != |
664 sizeof(sandbox_flags_)) { | 664 sizeof(sandbox_flags_)) { |
665 PLOG(ERROR) << "write"; | 665 PLOG(ERROR) << "write"; |
666 } | 666 } |
667 | 667 |
668 return false; | 668 return false; |
669 } | 669 } |
670 | 670 |
671 } // namespace content | 671 } // namespace content |
OLD | NEW |