[flutter_tools] exec rather than spawn subprocess from bin/internal/shared.sh (#99871)

This commit is contained in:
Christopher Fujino
2022-03-14 13:35:18 -07:00
committed by GitHub
parent b33249c344
commit bb4a5fa7ab
3 changed files with 98 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_tools/src/base/io.dart';
// This application will log to STDOUT and exit with 0 when it receives the
// SIGTERM signal.
Future<void> main() async {
final Stdout stdout = Stdio().stdout;
final Stream<ProcessSignal> interruptStream = ProcessSignal.sigterm.watch();
interruptStream.listen((_) {
// The test should assert that this was logged
stdout.writeln('Successfully received SIGTERM!');
exit(0);
});
// The test should wait for this message before sending SIGTERM, or else the
// listener may not have been registered.
stdout.writeln('Ready to receive signals');
await Future<void>.delayed(const Duration(seconds: 10));
stdout.writeln('Did not receive SIGTERM!');
exit(1);
}