Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Signal handling in C++

Reply
Thread Tools

Signal handling in C++

 
 
E.T. Grey
Guest
Posts: n/a
 
      10-14-2005
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?


 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      10-14-2005
E.T. Grey wrote:

> 1). What is the recommended way (i.e. best practise) to call a C
> callback function from a class?


See the FAQ to this newsgroup. Look at section 33 and especially question
33.2 "How do I pass a pointer-to-member-function to a signal handler, X
event callback, system call that starts a thread/task, etc?"

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
signal handling and (structured) exception handling Peter C++ 34 10-17-2009 10:03 AM
Re: How to make an internal signal embedded deep in hierarchy to a gloal output signal Weng Tianxiang VHDL 2 01-30-2007 12:58 PM
Aside from delta cycles and/or resolution functions, how can the effective value of a signal differ from a driving signal of its? Colin Paul Gloster VHDL 0 01-11-2007 01:31 PM
threading.Thread vs. signal.signal Jack Orenstein Python 0 09-17-2005 11:24 PM
Async-signal safe functions in signal handlers (unix) Michael Pronath Python 1 01-03-2005 01:10 PM



Advertisments