[tool] fallback to sigkill when closing Chromium (#135521)
This implements https://github.com/flutter/flutter/issues/132654#issuecomment-1738221257, namely: Make `Chromium.close` more robust: * Send `SIGTERM` and wait up to 5 seconds, if the process exited, great! Return from the function. * If the process has not exited, then send a `SIGKILL`, which is a much firmer way to exit a process. Same as before, wait up to 5 seconds, if the process exited, great! Return from the function. * If it still hasn't exited then give up trying to exit Chromium, just print a warning to the console and return from the function. Bonus: a few nullability fixes and extra `-v` logging. Fixes https://github.com/flutter/flutter/issues/132654
This commit is contained in:
@@ -213,10 +213,17 @@ class FakeProcess implements io.Process {
|
||||
/// The raw byte content of stdout.
|
||||
final List<int> _stdout;
|
||||
|
||||
/// The list of [kill] signals this process received so far.
|
||||
@visibleForTesting
|
||||
List<io.ProcessSignal> get signals => _signals;
|
||||
final List<io.ProcessSignal> _signals = <io.ProcessSignal>[];
|
||||
|
||||
@override
|
||||
bool kill([io.ProcessSignal signal = io.ProcessSignal.sigterm]) {
|
||||
_signals.add(signal);
|
||||
|
||||
// Killing a fake process has no effect.
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,6 +407,7 @@ abstract class FakeProcessManager implements ProcessManager {
|
||||
if (fakeProcess == null) {
|
||||
return false;
|
||||
}
|
||||
fakeProcess.kill(signal);
|
||||
if (fakeProcess._completer != null) {
|
||||
fakeProcess._completer.complete();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user