File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -218,8 +218,12 @@ int main(int argc, const char* argv[]) noexcept {
218218#else
219219 // Linux ctrl-c handler
220220
221- sigint_function = [&](int /* s*/ ) {
222- zit::logger ()->warn (" CTRL-C pressed. Stopping torrent(s)..." );
221+ sigint_function = [&](int s) {
222+ if (s == SIGINT) {
223+ zit::logger ()->warn (" CTRL-C pressed. Stopping torrent(s)..." );
224+ } else if (s == SIGTERM) {
225+ zit::logger ()->warn (" SIGTERM received. Stopping torrent(s)..." );
226+ }
223227 for (const auto & torrent : torrents) {
224228 torrent->stop ();
225229 }
@@ -232,11 +236,11 @@ int main(int argc, const char* argv[]) noexcept {
232236 };
233237
234238 // NOLINTBEGIN(cppcoreguidelines-pro-type-union-access,misc-include-cleaner)
235- struct sigaction sigIntHandler {};
239+ struct sigaction sigIntHandler{};
236240 sigIntHandler.sa_handler = sigint_handler;
237241 sigemptyset (&sigIntHandler.sa_mask );
238242 sigIntHandler.sa_flags = 0 ;
239- sigaction (SIGINT, &sigIntHandler, nullptr );
243+ sigaction (SIGINT | SIGTERM , &sigIntHandler, nullptr );
240244 // NOLINTEND(cppcoreguidelines-pro-type-union-access,misc-include-cleaner)
241245#endif // !WIN32
242246
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ bool Process::wait_for_exit(chrono::milliseconds timeout) {
102102
103103void Process::terminate () {
104104 if (m_pid) {
105+ logger ()->debug (" Sending SIGTERM to {}" , m_name);
105106 kill (m_pid, SIGTERM);
106107 if (!wait_for_exit (5s)) {
107108 logger ()->info (" {} still not dead, sending SIGKILL" , m_name);
You can’t perform that action at this time.
0 commit comments