@@ -2122,7 +2122,11 @@ static void append_to_generated_text_from_generated_token_probs(llama_server_con
2122
2122
}
2123
2123
2124
2124
std::function<void (int )> shutdown_handler;
2125
- inline void signal_handler (int signal) { shutdown_handler (signal ); }
2125
+
2126
+ inline void signal_handler (int signal) {
2127
+ exit (1 );
2128
+ }
2129
+
2126
2130
2127
2131
// ///////////////////////////////
2128
2132
// //////////////////////////////
@@ -2649,6 +2653,20 @@ void RunServer(const std::string& server_address) {
2649
2653
int main (int argc, char ** argv) {
2650
2654
std::string server_address (" localhost:50051" );
2651
2655
2656
+ #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
2657
+ struct sigaction sigint_action;
2658
+ sigint_action.sa_handler = signal_handler;
2659
+ sigemptyset (&sigint_action.sa_mask );
2660
+ sigint_action.sa_flags = 0 ;
2661
+ sigaction (SIGINT, &sigint_action, NULL );
2662
+ sigaction (SIGTERM, &sigint_action, NULL );
2663
+ #elif defined (_WIN32)
2664
+ auto console_ctrl_handler = +[](DWORD ctrl_type) -> BOOL {
2665
+ return (ctrl_type == CTRL_C_EVENT) ? (signal_handler (SIGINT), true ) : false ;
2666
+ };
2667
+ SetConsoleCtrlHandler (reinterpret_cast <PHANDLER_ROUTINE>(console_ctrl_handler), true );
2668
+ #endif
2669
+
2652
2670
// Define long and short options
2653
2671
struct option long_options[] = {
2654
2672
{" addr" , required_argument, nullptr , ' a' },
0 commit comments