diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-11 13:37:25 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-20 23:44:58 +0800 |
| commit | 4764b5f494fd5c0fe41dbc01779738c450198933 (patch) | |
| tree | a7880b2e6beb97152414cea6f451204c41ddf110 /src/main.cpp | |
| parent | 513623fc0e5182d37aaf91c6dc42670bca3aa888 (diff) | |
clang-format
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 44 |
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; } |
