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

[+] Added a SIGINT signal handler or by pressing ctrl + c for Linux operating systems.

parent c029de42
No related branches found
No related tags found
1 merge request!24Features 3398
......@@ -59,9 +59,15 @@
#include "wrapping_dap_chain_gdb.h"
#include "dap_common.h"
#include "signal.h"
#include "dap_server.h"
void sigfunc(int sig);
PyObject *python_cellframe_init(PyObject *self, PyObject *args);
void deinit_modules(void);
PyObject *python_cellframe_deinit(PyObject *self, PyObject *args);
static PyMethodDef CellFramePythonMethods[] = {
......
......@@ -21,8 +21,17 @@ static bool s_init_cs_dag_pos = false;
static bool s_init_chain_net_srv = false;
static bool s_init_ks = false;
static bool submodules_deint;
PyObject* CellFrame_error = NULL;
void sigfunc(int sig){
if (sig == SIGINT){
log_it(L_NOTICE, "Handler Ctrl+C");
dap_server_loop_stop();
deinit_modules();
}
}
PyObject *python_cellframe_init(PyObject *self, PyObject *args){
const char *app_name;
......@@ -32,6 +41,9 @@ PyObject *python_cellframe_init(PyObject *self, PyObject *args){
const char *JSON_str;
s_init_ks = true;
submodules_deint = false;
signal(SIGINT, sigfunc);
if (!PyArg_ParseTuple(args, "s", &JSON_str)){
PyErr_SetString(CellFrame_error, "ERROR in function call signature: can't get one String argument");
......@@ -460,36 +472,44 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){
return module;
}
PyObject *python_cellframe_deinit(PyObject *self, PyObject *args){
if (s_init_crypto){
dap_crypto_deinit();
dap_cert_deinit();
}
if (s_init_chain){
deinit_chain_py();
dap_chain_cs_deinit_py();
}
if (s_init_stream){
dap_stream_deinit();
}
if (s_init_stream_ctl){
dap_stream_ctl_deinit();
}
if (s_init_http_folder){
dap_http_folder_deinit();
}
if (s_init_http){
dap_http_deinit();
}
if (s_init_server_core){
dap_server_core_deinit();
}
if (s_init_ks){
dap_enc_ks_deinit();
void deinit_modules(void){
if (!submodules_deint){
log_it(L_NOTICE, "Start deint submodules");
if (s_init_crypto){
dap_crypto_deinit();
dap_cert_deinit();
}
if (s_init_chain){
deinit_chain_py();
dap_chain_cs_deinit_py();
}
if (s_init_stream){
dap_stream_deinit();
}
if (s_init_stream_ctl){
dap_stream_ctl_deinit();
}
if (s_init_http_folder){
dap_http_folder_deinit();
}
if (s_init_http){
dap_http_deinit();
}
if (s_init_server_core){
dap_server_core_deinit();
}
if (s_init_ks){
dap_enc_ks_deinit();
}
dap_config_close(g_config);
dap_config_deinit();
dap_common_deinit();
submodules_deint = true;
}
dap_config_close(g_config);
dap_config_deinit();
dap_common_deinit();
}
PyObject *python_cellframe_deinit(PyObject *self, PyObject *args){
deinit_modules();
return PyLong_FromLong(0);
}
......
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