| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/app/mash/mash_runner.h" | 5 #include "chrome/app/mash/mash_runner.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "services/service_manager/public/interfaces/service_factory.mojom.h" | 50 #include "services/service_manager/public/interfaces/service_factory.mojom.h" |
| 51 #include "services/service_manager/runner/common/client_util.h" | 51 #include "services/service_manager/runner/common/client_util.h" |
| 52 #include "services/service_manager/runner/common/switches.h" | 52 #include "services/service_manager/runner/common/switches.h" |
| 53 #include "services/service_manager/runner/init.h" | 53 #include "services/service_manager/runner/init.h" |
| 54 #include "services/ui/public/interfaces/constants.mojom.h" | 54 #include "services/ui/public/interfaces/constants.mojom.h" |
| 55 #include "ui/base/resource/resource_bundle.h" | 55 #include "ui/base/resource/resource_bundle.h" |
| 56 #include "ui/base/ui_base_paths.h" | 56 #include "ui/base/ui_base_paths.h" |
| 57 #include "ui/base/ui_base_switches.h" | 57 #include "ui/base/ui_base_switches.h" |
| 58 | 58 |
| 59 #if defined(OS_POSIX) | 59 #if defined(OS_POSIX) |
| 60 #include <signal.h> |
| 61 |
| 60 #include "base/threading/thread_task_runner_handle.h" | 62 #include "base/threading/thread_task_runner_handle.h" |
| 61 #include "chrome/app/shutdown_signal_handlers_posix.h" | 63 #include "chrome/app/shutdown_signal_handlers_posix.h" |
| 62 #endif | 64 #endif // defined(OS_POSIX) |
| 63 | 65 |
| 64 using service_manager::mojom::ServiceFactory; | 66 using service_manager::mojom::ServiceFactory; |
| 65 | 67 |
| 66 namespace { | 68 namespace { |
| 67 | 69 |
| 68 // kProcessType used to identify child processes. | 70 // kProcessType used to identify child processes. |
| 69 const char* kMashChild = "mash-child"; | 71 const char* kMashChild = "mash-child"; |
| 70 | 72 |
| 71 const char kChromeMashServiceName[] = "chrome_mash"; | 73 const char kChromeMashServiceName[] = "chrome_mash"; |
| 72 | 74 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // Quit the child process when the service quits. | 255 // Quit the child process when the service quits. |
| 254 context.SetQuitClosure(run_loop.QuitClosure()); | 256 context.SetQuitClosure(run_loop.QuitClosure()); |
| 255 run_loop.Run(); | 257 run_loop.Run(); |
| 256 // |context| must be destroyed before |message_loop|. | 258 // |context| must be destroyed before |message_loop|. |
| 257 } | 259 } |
| 258 | 260 |
| 259 int MashMain() { | 261 int MashMain() { |
| 260 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN) | 262 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN) |
| 261 base::RouteStdioToConsole(false); | 263 base::RouteStdioToConsole(false); |
| 262 #endif | 264 #endif |
| 265 |
| 266 #if defined(OS_POSIX) |
| 267 // We inherit the signal mask of our parent process, which might block signals |
| 268 // like SIGTERM that we need in order to cleanly shut down. Reset the signal |
| 269 // mask to unblock all signals. http://crbug.com/699777 |
| 270 sigset_t empty_signal_set; |
| 271 CHECK_EQ(0, sigemptyset(&empty_signal_set)); |
| 272 CHECK_EQ(0, sigprocmask(SIG_SETMASK, &empty_signal_set, nullptr)); |
| 273 #endif |
| 274 |
| 263 // TODO(sky): wire this up correctly. | 275 // TODO(sky): wire this up correctly. |
| 264 service_manager::InitializeLogging(); | 276 service_manager::InitializeLogging(); |
| 265 | 277 |
| 266 #if defined(OS_LINUX) | 278 #if defined(OS_LINUX) |
| 267 base::AtExitManager exit_manager; | 279 base::AtExitManager exit_manager; |
| 268 #endif | 280 #endif |
| 269 | 281 |
| 270 #if !defined(OFFICIAL_BUILD) | 282 #if !defined(OFFICIAL_BUILD) |
| 271 // Initialize stack dumping before initializing sandbox to make sure symbol | 283 // Initialize stack dumping before initializing sandbox to make sure symbol |
| 272 // names in all loaded libraries will be cached. | 284 // names in all loaded libraries will be cached. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 300 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { | 312 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { |
| 301 return; | 313 return; |
| 302 } | 314 } |
| 303 | 315 |
| 304 // Include the pid as logging may not have been initialized yet (the pid | 316 // Include the pid as logging may not have been initialized yet (the pid |
| 305 // printed out by logging is wrong). | 317 // printed out by logging is wrong). |
| 306 LOG(WARNING) << "waiting for debugger to attach for service " << service_name | 318 LOG(WARNING) << "waiting for debugger to attach for service " << service_name |
| 307 << " pid=" << base::Process::Current().Pid(); | 319 << " pid=" << base::Process::Current().Pid(); |
| 308 base::debug::WaitForDebugger(120, true); | 320 base::debug::WaitForDebugger(120, true); |
| 309 } | 321 } |
| OLD | NEW |