E
E.T. Grey
Hi,
I am trying to handle signals (SIGTERM, SIGILL and SIGABRT) in my C++ code.
I have member functions defined as follows:
/* Hack to allow signal handling */
void BaseProcess:
roc_death_catcher( int not_used ) {
proc_terminate() ;
}
In my initialization code for class BaseProcess, I set up the handlers
as follows:
signal(SIGTERM, proc_death_catcher);
signal(SIGILL, proc_death_catcher);
signal(SIGABRT, proc_death_catcher);
When I compile the code, I get the following error:
error C2664: 'signal' : cannot convert parameter 2 from 'void (int)' to
'void (__cdecl *)(int)'
The error appears to suggests that the calling convention is different
from what was expected.
If this inference is correct, it leads to a number of other questions:
1). What is the recommended way (i.e. best practise) to call a C
callback function from a class?
2). Do different instances of the class call into the same code (ala
static method) - or is the same copy of the callback used for all
instances of the class?
3). Is the answer to question 2 was that the same copy is used - then
this approach (calling C callbacks from C++ classes) is likely to be
thread *unsafe*. True?
I am trying to handle signals (SIGTERM, SIGILL and SIGABRT) in my C++ code.
I have member functions defined as follows:
/* Hack to allow signal handling */
void BaseProcess:
proc_terminate() ;
}
In my initialization code for class BaseProcess, I set up the handlers
as follows:
signal(SIGTERM, proc_death_catcher);
signal(SIGILL, proc_death_catcher);
signal(SIGABRT, proc_death_catcher);
When I compile the code, I get the following error:
error C2664: 'signal' : cannot convert parameter 2 from 'void (int)' to
'void (__cdecl *)(int)'
The error appears to suggests that the calling convention is different
from what was expected.
If this inference is correct, it leads to a number of other questions:
1). What is the recommended way (i.e. best practise) to call a C
callback function from a class?
2). Do different instances of the class call into the same code (ala
static method) - or is the same copy of the callback used for all
instances of the class?
3). Is the answer to question 2 was that the same copy is used - then
this approach (calling C callbacks from C++ classes) is likely to be
thread *unsafe*. True?