Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/service_manager/embedder/main.h" | 5 #include "services/service_manager/embedder/main.h" |
| 6 | 6 |
| 7 #include "base/allocator/features.h" | 7 #include "base/allocator/features.h" |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 101 |
| 102 MainDelegate* const main_delegate_; | 102 MainDelegate* const main_delegate_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(ServiceProcessLauncherDelegateImpl); | 104 DISALLOW_COPY_AND_ASSIGN(ServiceProcessLauncherDelegateImpl); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 107 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 108 | 108 |
| 109 // Setup signal-handling state: resanitize most signals, ignore SIGPIPE. | 109 // Setup signal-handling state: resanitize most signals, ignore SIGPIPE. |
| 110 void SetupSignalHandlers() { | 110 void SetupSignalHandlers() { |
| 111 #if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \ | |
|
jam
2017/04/28 00:24:50
can we use the same switch as in content? i..e mov
Oliver Chang
2017/04/28 17:05:06
Done. I put it in service_manager/embedder/switche
jam
2017/05/01 15:37:24
Even content doesn't have these checks, so I don't
Oliver Chang
2017/05/01 16:05:14
Sure, removed.
| |
| 112 !defined(MEMORY_SANITIZER) && !defined(THREAD_SANITIZER) && \ | |
| 113 !defined(UNDEFINED_SANITIZER) | |
| 111 // Sanitise our signal handling state. Signals that were ignored by our | 114 // Sanitise our signal handling state. Signals that were ignored by our |
| 112 // parent will also be ignored by us. We also inherit our parent's sigmask. | 115 // parent will also be ignored by us. We also inherit our parent's sigmask. |
| 113 sigset_t empty_signal_set; | 116 sigset_t empty_signal_set; |
| 114 CHECK_EQ(0, sigemptyset(&empty_signal_set)); | 117 CHECK_EQ(0, sigemptyset(&empty_signal_set)); |
| 115 CHECK_EQ(0, sigprocmask(SIG_SETMASK, &empty_signal_set, NULL)); | 118 CHECK_EQ(0, sigprocmask(SIG_SETMASK, &empty_signal_set, NULL)); |
| 116 | 119 |
| 117 struct sigaction sigact; | 120 struct sigaction sigact; |
| 118 memset(&sigact, 0, sizeof(sigact)); | 121 memset(&sigact, 0, sizeof(sigact)); |
| 119 sigact.sa_handler = SIG_DFL; | 122 sigact.sa_handler = SIG_DFL; |
| 120 static const int signals_to_reset[] = { | 123 static const int signals_to_reset[] = { |
| 121 SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, | 124 SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, |
| 122 SIGALRM, SIGTERM, SIGCHLD, SIGBUS, SIGTRAP}; // SIGPIPE is set below. | 125 SIGALRM, SIGTERM, SIGCHLD, SIGBUS, SIGTRAP}; // SIGPIPE is set below. |
| 123 for (unsigned i = 0; i < arraysize(signals_to_reset); i++) { | 126 for (unsigned i = 0; i < arraysize(signals_to_reset); i++) { |
| 124 CHECK_EQ(0, sigaction(signals_to_reset[i], &sigact, NULL)); | 127 CHECK_EQ(0, sigaction(signals_to_reset[i], &sigact, NULL)); |
| 125 } | 128 } |
| 126 | 129 |
| 127 // Always ignore SIGPIPE. We check the return value of write(). | 130 // Always ignore SIGPIPE. We check the return value of write(). |
| 128 CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN)); | 131 CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN)); |
| 132 #endif | |
| 129 } | 133 } |
| 130 | 134 |
| 131 void PopulateFDsFromCommandLine() { | 135 void PopulateFDsFromCommandLine() { |
| 132 const std::string& shared_file_param = | 136 const std::string& shared_file_param = |
| 133 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 137 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 134 switches::kSharedFiles); | 138 switches::kSharedFiles); |
| 135 if (shared_file_param.empty()) | 139 if (shared_file_param.empty()) |
| 136 return; | 140 return; |
| 137 | 141 |
| 138 base::Optional<std::map<int, std::string>> shared_file_descriptors = | 142 base::Optional<std::map<int, std::string>> shared_file_descriptors = |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 autorelease_pool.reset(); | 470 autorelease_pool.reset(); |
| 467 #endif | 471 #endif |
| 468 | 472 |
| 469 if (process_type == ProcessType::kEmbedder) | 473 if (process_type == ProcessType::kEmbedder) |
| 470 delegate->ShutDownEmbedderProcess(); | 474 delegate->ShutDownEmbedderProcess(); |
| 471 | 475 |
| 472 return exit_code; | 476 return exit_code; |
| 473 } | 477 } |
| 474 | 478 |
| 475 } // namespace service_manager | 479 } // namespace service_manager |
| OLD | NEW |