mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
set windows SIGINT
handler
This commit is contained in:
parent
94b25f5d1e
commit
2ef24dd1d9
10
src2/main.c
10
src2/main.c
@ -8,6 +8,15 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
static BOOL WINAPI sigint_handler(DWORD dwCtrlType) {
|
||||||
|
if(dwCtrlType == CTRL_C_EVENT) {
|
||||||
|
py_interrupt();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// set ctrl+c handler
|
// set ctrl+c handler
|
||||||
@ -39,6 +48,7 @@ int main(int argc, char** argv) {
|
|||||||
#if _WIN32
|
#if _WIN32
|
||||||
SetConsoleCP(CP_UTF8);
|
SetConsoleCP(CP_UTF8);
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigint_handler, TRUE);
|
||||||
#else
|
#else
|
||||||
signal(SIGINT, sigint_handler);
|
signal(SIGINT, sigint_handler);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user