stop method

Future<bool> stop(
  1. int exitCode, {
  2. String? reason,
})

Stops the process.

Implementation

Future<bool> stop(int exitCode, {String? reason}) async {
  if (_isolateCompleter.isCompleted) {
    await _cancelSignalListeners();
    return false;
  }

  await _cancelSignalListeners();

  if (_onStop != null) {
    await _onStop!(reason ?? 'Terminated normally.');
  }

  if (stopByKill) {
    isolate.kill();
  }

  if (!_isolateCompleter.isCompleted) {
    _isolateCompleter.complete(exitCode);
  }

  return true;
}