I'm having problems with signal function, i need that the second parameter call a function of my class
signal (SIGINT, myClass_function);
but as far as i know, it needs to be static void. And so i can not access the same instance of my object to access the variables that i need
Foo.h
class Foo {
public:
std::vector<my_struct> vm = std::vector<my_struct>(50);
static void myClass_function(int parameter) {
// handling signal here
// i need to access vm here
}
};
Foo.cpp
void Foo::something() {
// call signal
signal(SIGINT, myClass_function);
}
if user press ctrl+c, all data of vector vm need to be clean. No way to do that? anyone can help me?