startManaged function

Future<Process> startManaged(
  1. String executable,
  2. List<String> arguments, {
  3. String? label,
  4. Map<String, String>? environment,
  5. String? workingDirectory,
})

Starts a child that belongs to the current tool call: it is stopped if the call is abandoned, and forgotten once it exits. Call CallProgress.release to hand it over to outlive the call.

Implementation

Future<Process> startManaged(
  String executable,
  List<String> arguments, {
  String? label,
  Map<String, String>? environment,
  String? workingDirectory,
}) async {
  CallProgress.checkAlive();
  final process = ProcessRegistry.instance
      .track(await Process.start(executable, arguments, environment: environment, workingDirectory: workingDirectory));
  return _ownedByCall(process, label ?? describeCommand(executable, arguments));
}