-
Notifications
You must be signed in to change notification settings - Fork 907
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
Pressing Control+C twice on Windows stops chat #150
Comments
I second this. I was going to look into it this weekend, but I wasn't planning on doing a pull request since my experience with c++ isn't great. Would prefer if someone more experienced made the change. |
Update. I looked at the code and wrote a fix that should have worked, but it doesn't stop the second CTRL+C from existing the program. My approach assumed that the second CTRL+C was somehow happening due to asynchronous status of the is_interacting bool. I added another variable to check for multiple interrupts but it's not stopping the second one from ending the program. It does, however work, as it takes prevents the first time from exiting if you're in is_interactive == true. Here was my attempt so maybe someone else can figure it out.
Maybe there's an async issue. Maybe some other code in another thread is getting the interrupt before the handler in chat.cpp. At this point my understanding of C++ runtimes has hit its limit. Edit: Just also wanted to note I tried SIGBREAK but that didn't work at all. Since the application is piggy-backing off of SIGINT there may not be a graceful way to make this work. Someone would need to insert some other escape handler, like the escape key, to interrupt the generation. I will look into that, but have not done that before in C++. |
I've submitted PR #155 which will change the interrupt key to ESC. |
Ctrl+c is a default terminal interrupt for stopping the current running process, so unless your program is running in a loop that catches interrupts and handles them internally, your shell / terminal will handle it and end the currently focused process. Happens on Linux, Mac, and Windows as part of the ANSI standards. And ideally it shouldn't be used to interrupt the main loop either, as in cases like this you may double hit the key, accidentally killing the process. So requesting a different key combo trap like you did would be the best practices. |
In alpaca.cpp, ctrl+c is used interrupt text generation and return control to the user. On Windows, it works as expected when ctrl+c is pressed the first time. However, if you were to stop a text generation (press ctrl+c) for the second time, it will exit out of the script.
Is there anyway to fix this? Maybe change ctrl+c to something else like ctrl+d.
The text was updated successfully, but these errors were encountered: