[--Symptom--]
On many UNIX systems the interrupt sequence only works once, i.e.:

Prelude> {Interrupted!}
Prelude> <no effect>

instead of:

Prelude> {Interrupted!}
Prelude> {Interrupted!}
Prelude> <...>

[--Reason--]
POSIX specifies that the current signal should be masked by default
while in an interrupt handler. Within the SIGINT handler, hugs
longjmp's back to the main loop rather than returning from the
handler, so the signal remains masked.

[--Solution--]
Although ideally longjmp should not be used in this way, an alternate
resolution is to use the SA_NOMASK flag:

--- prelude.h   Fri Mar 19 22:19:00 1999
+++ prelude.h   Sun May  2 13:52:58 1999
@@ -365,7 +365,7 @@
 
 #else /* !DOS && !HANDLERS_CANT_LONGJMP - eg Unix */
 
-# define ctrlbrk(bh)   signal(SIGINT,bh)
+# define ctrlbrk(bh)   { struct sigaction sa; sa.sa_handler = bh;
sigemptyset(&sa.sa_mask); sa.sa_flags = SA_NOMASK; sigaction(SIGINT,
&sa, NULL); }
 # define allowBreak()   doNothing()
 
 #endif /* !DOS && !HANDLERS_CANT_LONGJMP */


Cheers,

 - matty


-- 
Matthew "Austin" Chapman
SysAdmin, Developer, Samba Team Member

"I have a dream... that one day, my three little children will be
judged not on the quality of their character, but on the content of
their code..."

Reply via email to