Chromium Code Reviews| Index: remoting/host/remoting_me2me_host.cc |
| diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc |
| index 65daa1260e1e6acf705b6c44eb5b6595aa26fdf7..3748aaef070fd6ef5bf338c3b2bc15dbf119412e 100644 |
| --- a/remoting/host/remoting_me2me_host.cc |
| +++ b/remoting/host/remoting_me2me_host.cc |
| @@ -54,6 +54,11 @@ |
| #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| #include "remoting/protocol/me2me_host_authenticator_factory.h" |
| +#if defined(OS_POSIX) |
| +#include <signal.h> |
| +#include "remoting/host/posix/signal_handler.h" |
| +#endif // defined(OS_POSIX) |
| + |
| #if defined(OS_MACOSX) |
| #include "base/mac/scoped_cftyperef.h" |
| #include "base/mac/scoped_nsautorelease_pool.h" |
| @@ -151,6 +156,15 @@ class HostProcess |
| return true; |
| } |
| +#if defined(OS_POSIX) |
| + void SigTermHandler(int signal_number) { |
| + DCHECK(signal_number == SIGTERM); |
| + DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| + LOG(INFO) << "Caught SIGTERM: Shutting down..."; |
| + Shutdown(kSuccessExitCode); |
| + } |
| +#endif |
| + |
| virtual void OnConfigUpdated(const std::string& serialized_config) OVERRIDE { |
| DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| @@ -217,7 +231,8 @@ class HostProcess |
| #if defined(OS_POSIX) |
| // Ignore SIGHUP sent by the daemon controller since we use |
| - // |ConfigFileWatcher| instead. |
| + // |ConfigFileWatcher| on Mac and Windows and read the config |
| + // from stdin on UNIX. |
| signal(SIGHUP, SIG_IGN); |
| #endif // defined(OS_POSIX) |
| @@ -229,6 +244,14 @@ class HostProcess |
| #endif // !defined(REMOTING_MULTI_PROCESS) |
| } |
| +#if defined(OS_POSIX) |
| + void ListenForShutdownSignal() { |
| + remoting::RegisterSignalHandler( |
| + SIGTERM, |
| + base::Bind(&HostProcess::SigTermHandler, base::Unretained(this))); |
| + } |
| +#endif // OS_POSIX |
| + |
| void CreateAuthenticatorFactory() { |
| DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| scoped_ptr<protocol::AuthenticatorFactory> factory( |
| @@ -263,6 +286,13 @@ class HostProcess |
| return; |
| } |
| +#if defined(OS_POSIX) |
| + context_->network_task_runner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&HostProcess::ListenForShutdownSignal, |
|
alexeypa (please no reviews)
2012/09/06 18:21:10
nit: You can bind to remoting::RegisterSignalHandl
|
| + base::Unretained(this))); |
| +#endif // OS_POSIX |
| + |
| StartWatchingConfigChanges(); |
| } |