[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:
@@ -191,15 +191,27 @@ class ProcessSignal {
|
||||
///
|
||||
/// Returns true if the signal was delivered, false otherwise.
|
||||
///
|
||||
/// On Windows, this can only be used with [ProcessSignal.sigterm], which
|
||||
/// terminates the process.
|
||||
/// On Windows, this can only be used with [sigterm], which terminates the
|
||||
/// process.
|
||||
///
|
||||
/// This is implemented by sending the signal using [Process.killPid].
|
||||
/// This is implemented by sending the signal using [io.Process.killPid] and
|
||||
/// therefore cannot be faked in tests. To fake sending signals in tests, use
|
||||
/// [kill] instead.
|
||||
bool send(int pid) {
|
||||
assert(!_platform.isWindows || this == ProcessSignal.sigterm);
|
||||
return io.Process.killPid(pid, _delegate);
|
||||
}
|
||||
|
||||
/// A more testable variant of [send].
|
||||
///
|
||||
/// Sends this signal to the given `process` by invoking [io.Process.kill].
|
||||
///
|
||||
/// In tests this method can be faked by passing a fake implementation of the
|
||||
/// [io.Process] interface.
|
||||
bool kill(io.Process process) {
|
||||
return process.kill(_delegate);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => _delegate.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user