Catching SIGTERM, cosmetic changes
This commit is contained in:
parent
18b92496e5
commit
ca261ca031
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
project (expandurl-mastodon
|
||||
VERSION 0.2.0
|
||||
VERSION 0.2.1
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
/*!
|
||||
* @brief Starts listening on Mastodon
|
||||
*/
|
||||
const bool start();
|
||||
const void start();
|
||||
/*!
|
||||
* @brief Stops listening on Mastodon
|
||||
*/
|
||||
|
|
|
@ -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<string> 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;
|
||||
|
|
|
@ -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…
Reference in New Issue
Block a user