Browse Source

Catching SIGTERM, cosmetic changes

master
tastytea 2 years ago
parent
commit
ca261ca031
Signed by: tastytea GPG Key ID: 59346E0EA35C67E5
4 changed files with 9 additions and 10 deletions
  1. +1
    -1
      CMakeLists.txt
  2. +1
    -1
      src/expandurl-mastodon.hpp
  3. +3
    -1
      src/main.cpp
  4. +4
    -7
      src/masto.cpp

+ 1
- 1
CMakeLists.txt View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (expandurl-mastodon
VERSION 0.2.0
VERSION 0.2.1
LANGUAGES CXX
)

+ 1
- 1
src/expandurl-mastodon.hpp View File

@ -67,7 +67,7 @@ public:
/*!
* @brief Starts listening on Mastodon
*/
const bool start();
const void start();
/*!
* @brief Stops listening on Mastodon
*/

+ 3
- 1
src/main.cpp View File

@ -33,6 +33,7 @@ void signal_handler(int signum)
switch (signum)
{
case SIGINT:
case SIGTERM:
if (!running)
{
cout << "Forced close.\n";
@ -66,6 +67,7 @@ const std::vector get_urls(const string &html)
int main(int argc, char *argv[])
{
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
curlpp::initialize();
Listener listener;
@ -124,8 +126,8 @@ int main(int argc, char *argv[])
}
}
}
listener.stop();
listener.stop();
curlpp::Cleanup();
return 0;

+ 4
- 7
src/masto.cpp View File

@ -29,10 +29,6 @@ Listener::Listener()
, _stream("")
, _ptr(nullptr)
, _running(false)
{
}
const bool Listener::start()
{
const string filepath = static_cast<const string>(getenv("HOME")) +
"/.config/expandurl-mastodon.cfg";
@ -52,9 +48,12 @@ const bool Listener::start()
else
{
cerr << "ERROR: Could not open " << filepath << '\n';
return false;
exit(1);
}
}
const void Listener::start()
{
_thread = std::thread([=]
{
_running = true;
@ -65,8 +64,6 @@ const bool Listener::start()
cerr << "DEBUG: Connection lost.\n";
_running = false;
});
return true;
}
const void Listener::stop()

Loading…
Cancel
Save