Using c++ function pointer as signal handler.

Viewed 1569

I'd like to add new handler to signal SIGUSR1 in my code. here's signal signature form header file signal.h :

void (*signal(int, void (*)(int)))(int);

My handler is a member function, so I'm using std::bind to make the function fit in signal accepted input.

myclass::my_handler(int x);

Here's my conversion of the member function to signal accepted input:

std::bind(&myclass::my_handler, this, std::placeholders::_1); 

However, std::bind return the c++ representation of function pointer (a.k.a std::function<void(int)>) and I need the C representation which is (void)(*)(int).

Should I do the casting forcefully, or perhaps there's c++ alternative for signal ?

Thanks

2 Answers
Related