spawnBackground method

Future<Process> spawnBackground(
  1. String executable,
  2. Iterable<String> arguments, {
  3. String? workingDirectory,
  4. Map<String, String>? environment,
  5. bool includeParentEnvironment = true,
  6. bool runInShell = false,
  7. ProcessStartMode mode = io.ProcessStartMode.normal,
})

Spawns a process by invoking executable with arguments.

This is similar to io.Process.start, but stdout and stderr is forwarded/routed between the process and host, similar to how a shell script works.

Returns a future that completes with a handle to the spawned process.

Implementation

Future<io.Process> spawnBackground(
  String executable,
  Iterable<String> arguments, {
  String? workingDirectory,
  Map<String, String>? environment,
  bool includeParentEnvironment = true,
  bool runInShell = false,
  io.ProcessStartMode mode = io.ProcessStartMode.normal,
}) async {
  final process = io.Process.start(
    executable,
    arguments.toList(),
    workingDirectory: workingDirectory,
    environment: environment,
    includeParentEnvironment: includeParentEnvironment,
    runInShell: runInShell,
    mode: mode,
  );
  return _ForwardingSpawn(
    await process,
    const Stream.empty(),
    _stdout,
    _stderr,
  );
}