chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Signal woes.


From: John Cowan
Subject: Re: [Chicken-users] Signal woes.
Date: Mon, 23 Jul 2007 02:42:18 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

Robin Lee Powell scripsit:

> > uh oh - running Scheme callbacks in interrupt handlers is
> > dangerous: the set of libc functions that may be called inside
> > them is restricted, and this is likely to highly risky.
> 
> Can you expand on this a bit?

It's a C restriction, not a Chicken one.  Basically, the C library (glibc
or whatever) is not guaranteed to be reentrant and generally is not.
That is, once one thread is inside the library, another thread can't
enter the library until the first has exited, but this is not enforced --
your program just goes kablooey.  For this purpose, interrupt handlers
are a separate thread of control.

The only absolutely guaranteed safely callable functions are abort, _Exit
(not the same as _exit or exit), and signal with the first argument equal
to the signal number that caused this handler to be entered.  In practice,
longjmp is not a problem either, though that's not an option in Chicken.
Most signal handlers just set a global variable to 1 and return.

-- 
John Cowan  address@hidden   http://ccil.org/~cowan
"The exception proves the rule."  Dimbulbs think: "Your counterexample proves
my theory."  Latin students think "'Probat' means 'tests': the exception puts
the rule to the proof."  But legal historians know it means "Evidence for an
exception is evidence of the existence of a rule in cases not excepted from."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]