diff --git a/src/event_manager.cc b/src/event_manager.cc index 0399283c..d42f53c8 100644 --- a/src/event_manager.cc +++ b/src/event_manager.cc @@ -133,7 +133,7 @@ void EventManager::force_signal(int fd) FD_SET(fd, &m_forced_fd); } -SignalHandler set_signal_wrapper(int signum, SignalHandler handler) +SignalHandler set_signal_handler(int signum, SignalHandler handler) { struct sigaction new_action, old_action; diff --git a/src/event_manager.hh b/src/event_manager.hh index d6b8412a..81bfc508 100644 --- a/src/event_manager.hh +++ b/src/event_manager.hh @@ -14,8 +14,6 @@ namespace Kakoune { -typedef void(*SignalHandler)(int); - enum class EventMode { Normal, @@ -94,7 +92,9 @@ private: TimePoint m_last; }; -SignalHandler set_signal_wrapper(int signum, SignalHandler handler); +using SignalHandler = void(*)(int); + +SignalHandler set_signal_handler(int signum, SignalHandler handler); } diff --git a/src/main.cc b/src/main.cc index 682b3fed..9414da30 100644 --- a/src/main.cc +++ b/src/main.cc @@ -293,16 +293,16 @@ std::unique_ptr create_local_ui(bool dummy_ui) { LocalUI() { - m_old_sighup = set_signal_wrapper(SIGHUP, [](int) { + m_old_sighup = set_signal_handler(SIGHUP, [](int) { ClientManager::instance().remove_client(*local_client, false); }); - m_old_sigtstp = set_signal_wrapper(SIGTSTP, [](int) { + m_old_sigtstp = set_signal_handler(SIGTSTP, [](int) { if (ClientManager::instance().count() == 1 and *ClientManager::instance().begin() == local_client) { // Suspend normally if we are the only client - auto current = set_signal_wrapper(SIGTSTP, static_cast(local_client->ui()).m_old_sigtstp); + auto current = set_signal_handler(SIGTSTP, static_cast(local_client->ui()).m_old_sigtstp); sigset_t unblock_sigtstp, old_mask; sigemptyset(&unblock_sigtstp); @@ -313,7 +313,7 @@ std::unique_ptr create_local_ui(bool dummy_ui) sigprocmask(SIG_SETMASK, &old_mask, nullptr); - set_signal_wrapper(SIGTSTP, current); + set_signal_handler(SIGTSTP, current); } else convert_to_client_pending = true; @@ -322,8 +322,8 @@ std::unique_ptr create_local_ui(bool dummy_ui) ~LocalUI() { - set_signal_wrapper(SIGHUP, m_old_sighup); - set_signal_wrapper(SIGTSTP, m_old_sigtstp); + set_signal_handler(SIGHUP, m_old_sighup); + set_signal_handler(SIGTSTP, m_old_sigtstp); local_client = nullptr; if (not convert_to_client_pending and not ClientManager::instance().empty()) @@ -431,7 +431,7 @@ int run_server(StringView session, StringView init_command, session, child)); exit(0); } - set_signal_wrapper(SIGTERM, [](int) { terminate = true; }); + set_signal_handler(SIGTERM, [](int) { terminate = true; }); } StringRegistry string_registry; @@ -661,13 +661,13 @@ int main(int argc, char* argv[]) { setlocale(LC_ALL, ""); - set_signal_wrapper(SIGSEGV, signal_handler); - set_signal_wrapper(SIGFPE, signal_handler); - set_signal_wrapper(SIGQUIT, signal_handler); - set_signal_wrapper(SIGTERM, signal_handler); - set_signal_wrapper(SIGPIPE, SIG_IGN); - set_signal_wrapper(SIGINT, [](int){}); - set_signal_wrapper(SIGCHLD, [](int){}); + set_signal_handler(SIGSEGV, signal_handler); + set_signal_handler(SIGFPE, signal_handler); + set_signal_handler(SIGQUIT, signal_handler); + set_signal_handler(SIGTERM, signal_handler); + set_signal_handler(SIGPIPE, SIG_IGN); + set_signal_handler(SIGINT, [](int){}); + set_signal_handler(SIGCHLD, [](int){}); Vector params; for (size_t i = 1; i < argc; ++i) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 6ffa72d7..a4f5b50c 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -250,8 +250,8 @@ NCursesUI::NCursesUI() enable_mouse(true); - set_signal_wrapper(SIGWINCH, on_term_resize); - set_signal_wrapper(SIGCONT, on_term_resize); + set_signal_handler(SIGWINCH, on_term_resize); + set_signal_handler(SIGCONT, on_term_resize); check_resize(true); @@ -262,8 +262,8 @@ NCursesUI::~NCursesUI() { enable_mouse(false); endwin(); - set_signal_wrapper(SIGWINCH, SIG_DFL); - set_signal_wrapper(SIGCONT, SIG_DFL); + set_signal_handler(SIGWINCH, SIG_DFL); + set_signal_handler(SIGCONT, SIG_DFL); } void NCursesUI::Window::create(const CharCoord& p, const CharCoord& s)