This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Using signals in redhat linux
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Claudio Lavecchia <Claudio dot Lavecchia at eurecom dot fr>, gcc-help at gcc dot gnu dot org
- Date: Thu, 05 Aug 2004 12:35:04 -0500
- Subject: Re: Using signals in redhat linux
- References: <41126A76.60802@eurecom.fr>
Hi Claudio,
Your question is off-topic for this forum. This forum does not support Red
Hat's 2.96 compiler (Red Hat has a forum for support of their compiler).
This forum does not support Red Hat Linux 7.3 (Red Hat has support forums
for that OS, including for developers).
That being said...
What are you NOT allowed to do within a signal?
Depending on the platform, there are MANY caveats about what you can and
cannot do within a signal handler.
Typically:
+ no I/O (such as a printf)
+ no OS API calls*
+ in C++ land, no exceptions
+ no longjmp
+ no read/writing non-volatile variables
+ no exit / abort
* The "no I/O" falls under this category, but it's so important I put it all
by itself anyway.
What should a signal handler do?
As little as possible, as quickly as possible. Set a flag, and then have
the regular program check that (volatile) flag for being changed. (I'm not
sure about mutexes and condvars within signal handlers... probably another
concern.)
In a multi-threading program, I'm not sure if there is any guarantee which
thread will be handling the signal. Probably varies from platform to
platform.
I'm not sure if any of the above is applicable to Red Hat Linux 7.3, or Red
Hat 2.96 compiler. I'm not sure if there is a attribute decoration for the
signal handling function in your situation (as I vaguely recall from my
Borland Turbo C days).
HTH,
--Eljay