| 3648 | std::atomic_flag is_terminating = ATOMIC_FLAG_INIT; |
| 3649 | |
| 3650 | inline void signal_handler(int signal) { |
| 3651 | if (is_terminating.test_and_set()) { |
| 3652 | // in case it hangs, we can force terminate the server by hitting Ctrl+C twice |
| 3653 | // this is for better developer experience, we can remove when the server is stable enough |
| 3654 | fprintf(stderr, "Received second interrupt, terminating immediately.\n"); |
| 3655 | exit(1); |
| 3656 | } |
| 3657 | |
| 3658 | shutdown_handler(signal); |
| 3659 | } |
| 3660 | |
| 3661 | int main(int argc, char ** argv) { |
| 3662 | // own arguments required by this example |