diff --git a/main/util/src/mill/util/PromptLogger.scala b/main/util/src/mill/util/PromptLogger.scala index 4459d33dd39..4c06142ffc7 100644 --- a/main/util/src/mill/util/PromptLogger.scala +++ b/main/util/src/mill/util/PromptLogger.scala @@ -63,23 +63,28 @@ private[mill] class PromptLogger( if (enableTicker) refreshPrompt() val promptUpdaterThread = new Thread( - () => + () => { + var lastUpdate = System.currentTimeMillis() while (!runningState.stopped) { - val promptUpdateInterval = - if (termDimensions._1.isDefined) promptUpdateIntervalMillis - else nonInteractivePromptUpdateIntervalMillis - - try Thread.sleep(promptUpdateInterval) + try Thread.sleep(promptUpdateIntervalMillis) catch { case e: InterruptedException => /*do nothing*/ } readTerminalDims(terminfoPath).foreach(termDimensions = _) - synchronized { - if (!runningState.paused && !runningState.stopped) refreshPrompt() + val now = System.currentTimeMillis() + if ( + termDimensions._1.nonEmpty || + (now - lastUpdate > nonInteractivePromptUpdateIntervalMillis) + ) { + lastUpdate = now + synchronized { + if (!runningState.paused && !runningState.stopped) refreshPrompt() + } } - }, + } + }, "prompt-logger-updater-thread" ) diff --git a/runner/client/src/mill/runner/client/MillClientMain.java b/runner/client/src/mill/runner/client/MillClientMain.java index aecee51404e..24452c2ac16 100644 --- a/runner/client/src/mill/runner/client/MillClientMain.java +++ b/runner/client/src/mill/runner/client/MillClientMain.java @@ -5,10 +5,7 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.Collections; -import mill.main.client.OutFiles; -import mill.main.client.ServerCouldNotBeStarted; -import mill.main.client.ServerLauncher; -import mill.main.client.Util; +import mill.main.client.*; import mill.main.client.lock.Locks; /** diff --git a/runner/client/src/mill/runner/client/MillProcessLauncher.java b/runner/client/src/mill/runner/client/MillProcessLauncher.java index 641b078ebeb..95ccfa02e77 100644 --- a/runner/client/src/mill/runner/client/MillProcessLauncher.java +++ b/runner/client/src/mill/runner/client/MillProcessLauncher.java @@ -32,8 +32,8 @@ static int launchMillNoServer(String[] args) throws Exception { boolean interrupted = false; try { - Process p = configureRunMillProcess(builder, processDir); MillProcessLauncher.runTermInfoThread(processDir); + Process p = configureRunMillProcess(builder, processDir); return p.waitFor(); } catch (InterruptedException e) { @@ -230,18 +230,25 @@ static void writeTerminalDims(boolean tputExists, Path serverDir) throws Excepti Files.write(serverDir.resolve(ServerFiles.terminfo), str.getBytes()); } + public static boolean checkTputExists() { + try { + getTerminalDim("cols", false); + getTerminalDim("lines", false); + return true; + } catch (Exception e) { + return false; + } + } + public static void runTermInfoThread(Path serverDir) throws Exception { + Path sandbox = serverDir.resolve(ServerFiles.sandbox); + Files.createDirectories(sandbox); + boolean tputExists = checkTputExists(); + + writeTerminalDims(tputExists, serverDir); Thread termInfoPropagatorThread = new Thread( () -> { try { - boolean tputExists; - try { - getTerminalDim("cols", false); - getTerminalDim("lines", false); - tputExists = true; - } catch (Exception e) { - tputExists = false; - } while (true) { writeTerminalDims(tputExists, serverDir); Thread.sleep(100);