mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-16 16:12:14 +11:00
✨ SIGTERM and other signal handling
This commit is contained in:
parent
1d76bc54bd
commit
8c911675c7
1 changed files with 11 additions and 10 deletions
7
main.cpp
7
main.cpp
|
|
@ -79,11 +79,9 @@ int main(int argc, char **argv)
|
|||
|
||||
//Sig handling
|
||||
struct sigaction sigIntHandler;
|
||||
|
||||
sigIntHandler.sa_handler = SaveSig;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
//Admin account
|
||||
|
|
@ -93,7 +91,8 @@ int main(int argc, char **argv)
|
|||
const unsigned long saving_freq = std::stoul(std::string(argv[2]));
|
||||
if (saving_freq) //if saving frequency is 0 then auto saving is turned off
|
||||
{
|
||||
std::thread([saving_freq]() {
|
||||
std::thread([saving_freq]()
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::minutes(saving_freq));
|
||||
|
|
@ -112,5 +111,7 @@ int main(int argc, char **argv)
|
|||
#endif
|
||||
.run();
|
||||
|
||||
SaveSig(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue