This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using signals in redhat linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]