summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3288b5c..115ad53 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,42 +1,42 @@
#include "chatServer.hpp"
-#include <csignal>
#include "log.hpp"
+#include <csignal>
#include <unistd.h>
static void handleSignal(int sig) {
- signal(sig, SIG_DFL);
+ signal(sig, SIG_DFL);
- log(SYS, "Caught signal: {}", sig);
+ log(SYS, "Caught signal: {}", sig);
- switch (sig) {
- default:
- // quick_exit(less cleanup) if the cleanup took too long
- signal(SIGALRM, [](int) { std::quick_exit(1); });
- alarm(5);
+ switch (sig) {
+ default:
+ // quick_exit(less cleanup) if the cleanup took too long
+ signal(SIGALRM, [](int) { std::quick_exit(1); });
+ alarm(5);
- std::exit(0);
- break;
- }
+ std::exit(0);
+ break;
+ }
}
static void registerSignals() {
- signal(SIGINT, handleSignal);
- signal(SIGTERM, handleSignal);
+ signal(SIGINT, handleSignal);
+ signal(SIGTERM, handleSignal);
- // client may not finish reading hence the server will receive SIGPIPE, we don't want that to just crash the server
- signal(SIGPIPE, SIG_IGN);
+ // client may not finish reading hence the server will receive SIGPIPE, we don't want that to just crash the server
+ signal(SIGPIPE, SIG_IGN);
}
// TODO: ARGC, ARGV. the CServer ctor should take a port number
int main() {
- registerSignals();
+ registerSignals();
- g_pChatServer = std::make_unique<CChatServer>();
- g_pChatServer->start();
+ g_pChatServer = std::make_unique<CChatServer>();
+ g_pChatServer->start();
- // died
- g_pChatServer->cleanup();
- g_pChatServer.reset();
+ // died
+ g_pChatServer->cleanup();
+ g_pChatServer.reset();
- return 0;
+ return 0;
}