Avoiding longjmp

Jim Shankland jas at ernie.Berkeley.EDU
Tue May 9 04:14:41 AEST 1989


In article <13624 at ncoast.ORG> allbery at ncoast.ORG (Brandon S. Allbery) writes:
>Might I suggest that the proper method for dealing with asynchronous signals
>of any sort without "longjmp" or its equivalent has been known for some time
>now.  It's called an event loop.

At the risk of getting into a "dessert topping/floor wax" argument:
the proper method for dealing with asynchronous signals is light-weight
processes (a.k.a. threads).  Forget signal handlers altogether:  you
dedicate a thread to signal handling by having it call a modified
pause().  A signal causes the pause()'d thread to run.  It can
abort its sister lwp's and/or start new ones, if it desires.
Obviously, you also need inter-thread synchronization primitives.

This approach has the advantage of making the parallelism implicit
in signal handlers explicit, allowing problems like heap corruption due
to signal in mid-malloc to be confronted head-on.

Jim Shankland
jas at ernie.berkeley.edu

"Blame it on the lies that killed us, blame it on the truth that ran us down"



More information about the Comp.unix.wizards mailing list