diff options
| author | Fuwn <[email protected]> | 2022-04-05 06:15:15 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-04-05 06:15:15 +0000 |
| commit | 28891f6a28289c3cc9dedade2fc120523655dc6e (patch) | |
| tree | 8f426dda5bdbcc12c54984f5ec3e2cd2bf13e8a2 | |
| parent | feat: maple 0.1.0 :star: (diff) | |
| download | maple-28891f6a28289c3cc9dedade2fc120523655dc6e.tar.xz maple-28891f6a28289c3cc9dedade2fc120523655dc6e.zip | |
refactor: pass lambda to signal
| -rw-r--r-- | maple/maple.cc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/maple/maple.cc b/maple/maple.cc index b645dc3..94b1005 100644 --- a/maple/maple.cc +++ b/maple/maple.cc @@ -32,14 +32,17 @@ static int maple_socket; static SSL_CTX *ssl_context; -auto handle_shutdown(int) -> void; - auto main() -> int { sockaddr_in socket_address {}; std::vector<std::string> gemini_files; // Try a graceful shutdown when a SIGINT is detected - signal(SIGINT, handle_shutdown); + signal(SIGINT, [](int signal_){ + std::cout << "shutdown(" << signal_ << ")" << std::endl; + + close(maple_socket); + SSL_CTX_free(ssl_context); + }); // Find and keep track of all Gemini files to serve for (const auto &entry : @@ -210,10 +213,3 @@ auto main() -> int { close(client); } } - -auto handle_shutdown(int signal) -> void { - std::cout << "shutdown(" << signal << ")" << std::endl; - - close(maple_socket); - SSL_CTX_free(ssl_context); -} |