Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update common.cpp #11605

Closed
wants to merge 1 commit into from
Closed

Update common.cpp #11605

wants to merge 1 commit into from

Conversation

magicse
Copy link
Contributor

@magicse magicse commented Feb 2, 2025

add #include as it was in earlier versions of common.cpp. Without this under Windows (gcc mingw) didn't work ctl+c in cmd.

Make sure to read the contributing guidelines before submitting a PR

add #include <thread> as it was in earlier versions of common.cpp. 
Without  this under Windows (gcc  mingw) didn't work ctl+c in cmd.
@ggerganov
Copy link
Owner

That's strange - <thread> is already included on line 33 above.

@magicse
Copy link
Contributor Author

magicse commented Feb 3, 2025

Hi @ggerganov
I know. But without #include in common.cpp, Windows (mingw) binaries (for example llama-server.exe) didn't process ctl+c signal.
I will try again build with and without #include to check and i'll come back with answer.

@ggerganov
Copy link
Owner

Maybe this issue is related: ggml-org/llama.vim#35

But I am not sure how including <thread> 2 times would make a difference compared to including it just once. Maybe something else is happening?

@magicse
Copy link
Contributor Author

magicse commented Feb 4, 2025

Hi @ggerganov .
I made research. And this problem not with common.cpp but with server.cpp.
It due registration of ctrl+c event procession after ctx_server.queue_tasks.start_loop(); in server.cpp.
I think it need mover upper.

 ctx_server.queue_tasks.start_loop();
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
    struct sigaction sigint_action;
    sigint_action.sa_handler = signal_handler;
    sigemptyset (&sigint_action.sa_mask);
    sigint_action.sa_flags = 0;
    sigaction(SIGINT, &sigint_action, NULL);
    sigaction(SIGTERM, &sigint_action, NULL);
#elif defined (_WIN32)
    auto console_ctrl_handler = +[](DWORD ctrl_type) -> BOOL {
        return (ctrl_type == CTRL_C_EVENT) ? (signal_handler(SIGINT), true) : false;
    };
    SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
#endif

If i move registration of ctrl+c event upper it process ctrl+c well.

@ggerganov
Copy link
Owner

Thanks. Feel free to open a PR with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants