From 868d8c145849efcd3653a55074d55dfe01d4b406 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Mon, 23 Jul 2018 18:53:19 +0100 Subject: [PATCH] In microbenchmarks, ensure flutter quits by sending `q` to stdin (#19400) * Tell flutter to quit directly Fixes #19208. * Tweak comment --- dev/devicelab/lib/tasks/microbenchmarks.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dev/devicelab/lib/tasks/microbenchmarks.dart b/dev/devicelab/lib/tasks/microbenchmarks.dart index 367896fcb6..1c22da52d4 100644 --- a/dev/devicelab/lib/tasks/microbenchmarks.dart +++ b/dev/devicelab/lib/tasks/microbenchmarks.dart @@ -96,7 +96,7 @@ Future> _readJsonResults(Process process) { final StreamSubscription stdoutSub = process.stdout .transform(const Utf8Decoder()) .transform(const LineSplitter()) - .listen((String line) { + .listen((String line) async { print(line); if (line.contains(jsonStart)) { @@ -124,8 +124,14 @@ Future> _readJsonResults(Process process) { jsonStarted = false; processWasKilledIntentionally = true; resultsHaveBeenParsed = true; - - process.kill(ProcessSignal.sigint); // flutter run doesn't quit automatically + // Sending a SIGINT/SIGTERM to the process here isn't reliable because [process] is + // the shell (flutter is a shell script) and doesn't pass the signal on. + // Sending a `q` is an instruction to quit using the console runner. + // See https://github.com/flutter/flutter/issues/19208 + process.stdin.write('q'); + await process.stdin.flush(); + // Also send a kill signal in case the `q` above didn't work. + process.kill(ProcessSignal.sigint); // ignore: deprecated_member_use try { completer.complete(new Map.from(json.decode(jsonOutput))); } catch (ex) {