andd newlines and SIGHUP handling

This commit is contained in:
PoliEcho 2024-11-09 12:29:08 +01:00
parent b1be6e227d
commit 62f3c55f93
2 changed files with 8 additions and 4 deletions

View File

@ -3,17 +3,20 @@
void safe_exit(int code) {
switch (code) {
case SIGTERM:
std::cerr << "received SIGTERM exiting...\n";
std::cerr << "\nreceived SIGTERM exiting...\n";
break;
case SIGINT:
std::cerr << "received SIGINT exiting...\n";
std::cerr << "\nreceived SIGINT exiting...\n";
break;
case SIGQUIT:
std::cerr << "received SIGQUIT exiting...\n";
std::cerr << "\nreceived SIGQUIT exiting...\n";
break;
case SIGHUP:
std::cerr << "\nreceived SIGHUP exiting...\n";
break;
case SIGSEGV:
std::cerr << "received SIGSEGV(segmentaiton fault) exiting...\nIf this "
std::cerr << "\nreceived SIGSEGV(segmentaiton fault) exiting...\nIf this "
"repeats please report this bug\n";
break;
}

View File

@ -14,6 +14,7 @@ int main(int argc, char **argv) {
signal(SIGTERM, safe_exit);
signal(SIGINT, safe_exit);
signal(SIGQUIT, safe_exit);
signal(SIGHUP, safe_exit);
// error signal handlers
signal(SIGSEGV, safe_exit);