From d3ac5274b3ba767d12a6266a6ca9958ea30c1b14 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Tue, 8 May 2018 13:18:13 -0700 Subject: [PATCH] Revert back to non-blocking watch termination condition A thread blocking on System.in.read() cannot be interrupted, so check System.in.available before blocking. This is how it used to work. It requires https://github.com/sbt/io/pull/149 or else a cpu will be pegged by the EventMonitor user input thread spinning on System.in.available. --- main-command/src/main/scala/sbt/Watched.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main-command/src/main/scala/sbt/Watched.scala b/main-command/src/main/scala/sbt/Watched.scala index 73e177f83..4daea053b 100644 --- a/main-command/src/main/scala/sbt/Watched.scala +++ b/main-command/src/main/scala/sbt/Watched.scala @@ -100,7 +100,7 @@ object Watched { def executeContinuously(watched: Watched, s: State, next: String, repeat: String): State = { @tailrec def shouldTerminate: Boolean = - watched.terminateWatch(System.in.read()) || shouldTerminate + (System.in.available > 0) && (watched.terminateWatch(System.in.read()) || shouldTerminate) val log = s.log val logger = new EventMonitor.Logger { override def debug(msg: => Any): Unit = log.debug(msg.toString)