ProcessSpawner

public protocol ProcessSpawner

The low-level interface to spawn a process

  • Spawns a subprocess.

    Note

    all unmapped descriptors will be closed

    Declaration

    Swift

    func spawn(command: String, arguments: [String], env: [String : String], fdMap: FDMap, pathResolve: Bool) -> SpawnResult

    Parameters

    command

    process to spawn

    arguments

    arguments to pass

    env

    all environment variables for subprocess

    fdMap

    a list of file descriptor remappings, src -> dst (can be equal)

    pathResolve

    if true, search for executable in PATH

    Return Value

    pid of spawned process or error if failed

  • Add a callback for child process exiting

    Declaration

    Swift

    func reapAsync(pid: pid_t, queue: DispatchQueue, callback: @escaping (Int32) -> Void)

    Parameters

    pid

    pid of child process

    callback

    called with exit code when child exits

    queue

    queue the callback is executed on