snakeoil.process.spawn module

subprocess related functionality

snakeoil.process.spawn.bash_version(force: bool = False)[source]

Get the system bash version of the form major.minor.patch.

snakeoil.process.spawn.cleanup_pids(pids: Iterable[int] = None)[source]

reap list of pids if specified, else all children

snakeoil.process.spawn.spawn(mycommand: str | Sequence[str], env: dict[str, str] | None = None, name: str | None = None, fd_pipes: dict[int, int] | None = None, returnpid: bool = False, uid: int | None = None, gid: int | None = None, groups: Sequence[int] | None = None, umask: int | None = None, cwd: str | None = None, pgid: int | None = None)[source]

wrapper around execve

Parameters:
  • name – controls what the process is named (what it would show up as under top for example)

  • fd_pipes (mapping from existing fd to fd (inside the new process)) – controls what fd’s are left open in the spawned process-

  • returnpid – controls whether spawn waits for the process to finish, or returns the pid.

snakeoil.process.spawn.spawn_bash(mycommand: str | Iterable[str], debug: bool = False, name: str = None, **kwds)[source]

spawn the command via bash -c

snakeoil.process.spawn.spawn_get_output(mycommand: str | Iterable[str], spawn_type=None, raw_exit_code: bool = False, collect_fds: Iterable[int] = (1,), fd_pipes: dict[int, int] | None = None, split_lines: bool = True, **kwds)[source]

Call spawn, collecting the output to fd’s specified in collect_fds list.

Parameters:

spawn_type – the passed in function to call- typically spawn_bash() spawn(), or spawn_sandbox(). Defaults to spawn().

snakeoil.process.spawn.spawn_sandbox(mycommand: str | Iterable[str], name: str = None, **kwds)[source]

spawn the command under sandboxed