killGracefully method
Implementation
Future<int> killGracefully(
Process process, {
bool debugLogging = false,
}) async {
final processId = process.pid;
if (debugLogging) {
print(
'${DateTime.now()}: Cancelling all stream subscriptions for process '
'$processId before killing.',
);
}
await cancelAllStreamSubscriptions();
if (debugLogging) {
print('${DateTime.now()}: Sending SIGTERM to $processId.');
}
Process.killPid(processId);
return process.exitCode.timeout(
killTimeout,
onTimeout: () => killForcefully(process, debugLogging: debugLogging),
);
}