diff options
author | Max Kellermann <max@musicpd.org> | 2019-02-05 21:33:56 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-02-05 21:36:51 +0100 |
commit | 096c23f27de97182b2902ce8aa51d8bd2b55f865 (patch) | |
tree | e66191db7d86efaad80aa68c8197284d353745f7 | |
parent | 40bde1eac9822b0806c60fa9bb656993d564b586 (diff) |
unix/SignalHandlers: add RAII class
-rw-r--r-- | src/Main.cxx | 5 | ||||
-rw-r--r-- | src/unix/SignalHandlers.hxx | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/Main.cxx b/src/Main.cxx index 06d7b1915..084d1ad4f 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -564,7 +564,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config) #ifndef ANDROID setup_log_output(); - SignalHandlersInit(instance->event_loop); + const ScopeSignalHandlersInit signal_handlers_init(instance->event_loop); #endif instance->io_thread.Start(); @@ -676,9 +676,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config) #endif instance->rtio_thread.Stop(); instance->io_thread.Stop(); -#ifndef ANDROID - SignalHandlersFinish(); -#endif return EXIT_SUCCESS; } diff --git a/src/unix/SignalHandlers.hxx b/src/unix/SignalHandlers.hxx index d17c0504c..4808f97e5 100644 --- a/src/unix/SignalHandlers.hxx +++ b/src/unix/SignalHandlers.hxx @@ -28,4 +28,15 @@ SignalHandlersInit(EventLoop &loop); void SignalHandlersFinish() noexcept; +class ScopeSignalHandlersInit { +public: + ScopeSignalHandlersInit(EventLoop &loop) { + SignalHandlersInit(loop); + } + + ~ScopeSignalHandlersInit() noexcept { + SignalHandlersFinish(); + } +}; + #endif |