All Downloads are FREE. Search and download functionalities are using the official Maven repository.

System.posix_interrupt.scala Maven / Gradle / Ivy

There is a newer version: 0.5
Show newest version
/*  Title:      Pure/System/posix_interrupt.scala
    Author:     Makarius

Support for POSIX interrupts (bypassed on Windows).
*/

package isabelle


import sun.misc.{Signal, SignalHandler}


object POSIX_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 }
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy