diff --git a/src/client/main.cpp b/src/client/main.cpp index c182fe0..b832efb 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char** argv) { try { log("ColumnLynx Client, Version " + getVersion()); - log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSE for details."); + log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSES/ for details."); LibSodiumWrapper sodiumWrapper = LibSodiumWrapper(); @@ -78,7 +78,7 @@ int main(int argc, char** argv) { // Client is running // TODO: SIGINT or SIGTERM seems to not kill this instantly! - while (client->isConnected() || !client->isHandshakeComplete() || !done) { + while ((client->isConnected() || !client->isHandshakeComplete()) && !done) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Temp wait if (client->isHandshakeComplete()) { diff --git a/src/server/main.cpp b/src/server/main.cpp index fdddac3..385dde9 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -18,26 +18,27 @@ using namespace ColumnLynx::Net::UDP; volatile sig_atomic_t done = 0; -/*void signalHandler(int signum) { +void signalHandler(int signum) { if (signum == SIGINT || signum == SIGTERM) { log("Received termination signal. Shutting down server gracefully."); done = 1; } -}*/ +} int main(int argc, char** argv) { + // Capture SIGINT and SIGTERM for graceful shutdown + struct sigaction action; + memset(&action, 0, sizeof(struct sigaction)); + action.sa_handler = signalHandler; + sigaction(SIGINT, &action, nullptr); + sigaction(SIGTERM, &action, nullptr); + PanicHandler::init(); try { - // Catch SIGINT and SIGTERM for graceful shutdown - /*struct sigaction action; - memset(&action, 0, sizeof(struct sigaction)); - action.sa_handler = signalHandler; - sigaction(SIGINT, &action, nullptr); - sigaction(SIGTERM, &action, nullptr);*/ log("ColumnLynx Server, Version " + getVersion()); - log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSE for details."); + log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSES/ for details."); // Generate a temporary keypair, replace with actual CA signed keys later (Note, these are stored in memory) LibSodiumWrapper sodiumWrapper = LibSodiumWrapper();