# HG changeset patch # User wenzelm # Date 1361615265 -3600 # Node ID ca13a14cc52e346191c051aaa1f34b98b00836cb # Parent 5013ed756a787678aadd7b2eff316f6da094f482 support for POSIX interrupts (bypassed on Windows); diff -r 5013ed756a78 -r ca13a14cc52e src/Pure/System/interrupt.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Pure/System/interrupt.scala Sat Feb 23 11:27:45 2013 +0100 @@ -0,0 +1,29 @@ +/* Title: Pure/System/interrupt.scala + Author: Makarius + +Support for POSIX interrupts (bypassed on Windows). +*/ + +package isabelle + + +import sun.misc.{Signal, SignalHandler} + + +object Interrupt +{ + def handler[A](h: => Unit)(e: => A): A = + { + val SIGINT = new Signal("INT") + val new_handler = new SignalHandler { def handle(s: Signal) { h } } + val old_handler = Signal.handle(SIGINT, new_handler) + try { e } finally { Signal.handle(SIGINT, old_handler) } + } + + def exception[A](e: => A): A = + { + val thread = Thread.currentThread + handler { thread.interrupt } { e } + } +} + diff -r 5013ed756a78 -r ca13a14cc52e src/Pure/build-jars --- a/src/Pure/build-jars Fri Feb 22 20:25:51 2013 +0100 +++ b/src/Pure/build-jars Sat Feb 23 11:27:45 2013 +0100 @@ -44,6 +44,7 @@ System/event_bus.scala System/gui_setup.scala System/html5_panel.scala + System/interrupt.scala System/invoke_scala.scala System/isabelle_charset.scala System/isabelle_process.scala