Skip to content
Snippets Groups Projects
Commit 711f850c authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[+] Added handler pressing keys Ctrl+C for Windows.

parent 65326d8a
No related branches found
No related tags found
1 merge request!24Features 3398
......@@ -59,10 +59,16 @@
#include "wrapping_dap_chain_gdb.h"
#include "dap_common.h"
#include "signal.h"
#include "dap_server.h"
#ifdef _WIN32
#include "Windows.h"
BOOL WINAPI consoleHandler(DWORD);
#else
#include "signal.h"
void sigfunc(int sig);
#endif
PyObject *python_cellframe_init(PyObject *self, PyObject *args);
......
......@@ -25,6 +25,19 @@ static bool submodules_deint;
PyObject* CellFrame_error = NULL;
#ifdef _WIN32
BOOL WINAPI consoleHandler(DWORD dwType){
if (dwType == CTRL_C_EVENT){
log_it(L_NOTICE, "Handler Ctrl+C");
dap_server_loop_stop();
deinit_modules();
}
return TRUE;
}
#else
void sigfunc(int sig){
if (sig == SIGINT){
log_it(L_NOTICE, "Handler Ctrl+C");
......@@ -32,6 +45,7 @@ void sigfunc(int sig){
deinit_modules();
}
}
#endif
PyObject *python_cellframe_init(PyObject *self, PyObject *args){
const char *app_name;
......@@ -43,7 +57,11 @@ PyObject *python_cellframe_init(PyObject *self, PyObject *args){
s_init_ks = true;
submodules_deint = false;
signal(SIGINT, sigfunc);
#ifdef _WIN32
setConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE);
#else
signal(SIGINT, sigfunc);
#endif
if (!PyArg_ParseTuple(args, "s", &JSON_str)){
PyErr_SetString(CellFrame_error, "ERROR in function call signature: can't get one String argument");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment