On Fri, Jan 8, 2010 at 2:06 PM, Gabriel M. Beddingfield
<gabrbedd(a)gmail.com> wrote:
On Fri, 8 Jan 2010, Chris Cannam wrote:
This is far too weak -- it _cannot_ safely be done from a signal handler.
Why not?
A signal handler can be called at any time, so can't safely interact
with its environment (even with the heap) in any meaningful way.
e.g. C99:
"If the signal occurs other than as the result of calling the abort or
raise function, the
behavior is undefined if the signal handler refers to any object with
static storage duration
other than by assigning a value to an object declared as volatile
sig_atomic_t, or
the signal handler calls any function in the standard library other
than the abort
function, the _Exit function, or the signal function with the first
argument equal to
the signal number corresponding to the signal that caused the
invocation of the handler."
So the only thing you're allowed to do, besides exit, is assign to a
global volatile sig_atomic_t variable and return.
Realistically you may be able to get away with more than that, but
saving a document is definitely out.
Chris