more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
authorwenzelm
Fri May 02 23:25:56 2014 +0200 (2014-05-02)
changeset 568375a598f1eecfd
parent 56836 69531d86d77e
child 56838 477cd67f963f
more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
src/Pure/Tools/build.scala
     1.1 --- a/src/Pure/Tools/build.scala	Fri May 02 23:06:05 2014 +0200
     1.2 +++ b/src/Pure/Tools/build.scala	Fri May 02 23:25:56 2014 +0200
     1.3 @@ -38,7 +38,11 @@
     1.4  
     1.5      @volatile private var is_stopped = false
     1.6      def interrupt_handler[A](e: => A): A = Interrupt.handler { is_stopped = true } { e }
     1.7 -    override def stopped: Boolean = is_stopped
     1.8 +    override def stopped: Boolean =
     1.9 +    {
    1.10 +      if (Thread.interrupted) is_stopped = true
    1.11 +      is_stopped
    1.12 +    }
    1.13    }
    1.14  
    1.15  
    1.16 @@ -807,7 +811,11 @@
    1.17      // scheduler loop
    1.18      case class Result(current: Boolean, heap: String, rc: Int)
    1.19  
    1.20 -    def sleep(): Unit = Thread.sleep(500)
    1.21 +    def sleep()
    1.22 +    {
    1.23 +      try { Thread.sleep(500) }
    1.24 +      catch { case Exn.Interrupt() => Thread.currentThread.interrupt }
    1.25 +    }
    1.26  
    1.27      @tailrec def loop(
    1.28        pending: Queue,