diff --git a/cli/helper.cpp b/cli/helper.cpp index 813c859..a9e8619 100644 --- a/cli/helper.cpp +++ b/cli/helper.cpp @@ -40,7 +40,7 @@ std::function InterruptHandler::s_handler; bool InterruptHandler::s_handlerRegistered = false; /*! - * \brief Registers the specified \a handler for SIGINT as long as this object is alive. + * \brief Registers the specified \a handler for SIGINT and SIGTERM as long as this object is alive. * \remarks The specified \a handler should only call functions which are permitted to be used in signal handlers * (eg. use POSIX write() instread of std::cout). * \throws Throws std::runtime_error when attempting to create a 2nd instance. @@ -57,6 +57,7 @@ InterruptHandler::InterruptHandler(std::function handler) if (!s_handlerRegistered) { s_handlerRegistered = true; signal(SIGINT, &InterruptHandler::handler); + signal(SIGTERM, &InterruptHandler::handler); } } @@ -84,9 +85,9 @@ void InterruptHandler::handler(int signum) write(STDOUT_FILENO, "\n", 1); } if (EscapeCodes::enabled) { - write(STDOUT_FILENO, "\e[1;33mWarning:\e[0m \e[1mInterrupt received, trying to abort ongoing process ...\e[0m\n", 84); + write(STDOUT_FILENO, "\e[1;33mWarning:\e[0m \e[1mSignal received, trying to abort ongoing process ...\e[0m\n", 84); } else { - write(STDOUT_FILENO, "Warning: Interrupt received, trying to abort ongoing process ...\n", 65); + write(STDOUT_FILENO, "Warning: Signal received, trying to abort ongoing process ...\n", 65); } // call custom handler