more explicit console interrupt handling;
authorwenzelm
Sat Feb 23 12:55:59 2013 +0100 (2013-02-23)
changeset 5125203d1fca818a4
parent 51251 d55cce4d72dd
child 51253 ab4c296a1e60
more explicit console interrupt handling;
src/Pure/Tools/build.scala
     1.1 --- a/src/Pure/Tools/build.scala	Sat Feb 23 12:28:18 2013 +0100
     1.2 +++ b/src/Pure/Tools/build.scala	Sat Feb 23 12:55:59 2013 +0100
     1.3 @@ -35,6 +35,10 @@
     1.4      override def echo(msg: String) { java.lang.System.out.println(msg) }
     1.5      override def theory(session: String, theory: String): Unit =
     1.6        if (verbose) echo(session + ": theory " + theory)
     1.7 +
     1.8 +    @volatile private var is_stopped = false
     1.9 +    def interrupt_handler[A](e: => A): A = Interrupt.handler { is_stopped = true } { e }
    1.10 +    override def stopped: Boolean = { val b = is_stopped; is_stopped = false; b  }
    1.11    }
    1.12  
    1.13  
    1.14 @@ -889,9 +893,12 @@
    1.15              val dirs =
    1.16                select_dirs.map(d => (true, Path.explode(d))) :::
    1.17                include_dirs.map(d => (false, Path.explode(d)))
    1.18 -            build(new Build.Console_Progress(verbose), options, requirements, all_sessions,
    1.19 -              build_heap, clean_build, dirs, session_groups, max_jobs, list_files, no_build,
    1.20 -              system_mode, verbose, sessions)
    1.21 +            val progress = new Build.Console_Progress(verbose)
    1.22 +            progress.interrupt_handler {
    1.23 +              build(progress, options, requirements, all_sessions,
    1.24 +                build_heap, clean_build, dirs, session_groups, max_jobs, list_files, no_build,
    1.25 +                system_mode, verbose, sessions)
    1.26 +            }
    1.27          case _ => error("Bad arguments:\n" + cat_lines(args))
    1.28        }
    1.29      }