runCmdDetached function
Future<Process>
runCmdDetached(
- String cmd,
- List<
String> args, [ - ExecDetachedOptions options = const ExecDetachedOptions()
Spawn cmd with args detached from the parent process.
TS-source counterpart: runCmdDetached. The TS version returns the child's
pid synchronously; Dart's Process.start is async, so this returns a
Future<Process>. Awaiting the future yields the live handle — the caller
owns its lifecycle (kill / exitCode) and can read process.pid.
Implementation
Future<Process> runCmdDetached(
String cmd,
List<String> args, [
ExecDetachedOptions options = const ExecDetachedOptions(),
]) async {
final executable = _normalizeExecutableCommand(cmd);
try {
final process = await Process.start(
executable,
args,
workingDirectory: options.cwd,
environment: options.env,
mode: ProcessStartMode.detached,
);
return process;
} on ProcessException catch (e) {
throw _translateSpawnFailure(e, executable, cmd, args);
}
}