diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c341b79a..bfbad063e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## 1.50.1 +### Command Line Interface + +* Fix a bug where moving the `--watch` command to the background would + unexpectedly cause the command to stop running unless the standard input + stream was a TTY. + ### Embedded Sass * The JS embedded host and the embedded compiler will now properly avoid diff --git a/lib/src/io/interface.dart b/lib/src/io/interface.dart index f25b6cc3e..8e6b5785c 100644 --- a/lib/src/io/interface.dart +++ b/lib/src/io/interface.dart @@ -95,10 +95,12 @@ String? getEnvironmentVariable(String name) => throw ''; int get exitCode => throw ''; set exitCode(int value) => throw ''; -/// If stdin is a TTY, returns a [CancelableOperation] that completes once it -/// closes. +/// Returns a [CancelableOperation] that completes when stdin closes. /// -/// Otherwise, returns a [CancelableOperation] that never completes. +/// Note that if stdin is a TTY, the operation never completes. This is to +/// avoid interfering with background job systems where reading from stdin +/// and then moving the process to the background would incorrectly cause +/// the job to stop. /// /// As long as this is uncanceled, it will monopolize stdin so that nothing else /// can read from it. diff --git a/lib/src/io/node.dart b/lib/src/io/node.dart index 97a13b009..f38c2e2f0 100644 --- a/lib/src/io/node.dart +++ b/lib/src/io/node.dart @@ -218,7 +218,7 @@ set exitCode(int code) => process.exitCode = code; CancelableOperation onStdinClose() { var completer = CancelableCompleter(); - if (isStdinTTY == true) { + if (isStdinTTY != true) { process.stdin.on('end', allowInterop(() => completer.complete())); } return completer.operation; diff --git a/lib/src/io/vm.dart b/lib/src/io/vm.dart index 72d74fde4..22ff69f8d 100644 --- a/lib/src/io/vm.dart +++ b/lib/src/io/vm.dart @@ -91,8 +91,8 @@ DateTime modificationTime(String path) { String? getEnvironmentVariable(String name) => io.Platform.environment[name]; CancelableOperation onStdinClose() => io.stdin.hasTerminal - ? CancelableOperation.fromSubscription(io.stdin.listen(null)) - : CancelableCompleter().operation; + ? CancelableCompleter().operation + : CancelableOperation.fromSubscription(io.stdin.listen(null)); Future> watchDir(String path, {bool poll = false}) async { var watcher = poll ? PollingDirectoryWatcher(path) : DirectoryWatcher(path);