On this page
Subprocess management for launching and monitoring the Claude Code CLI process, including graceful shutdown and atexit cleanup.
#claudestream._process
#claudestream._process
Subprocess management for launching and monitoring the Claude Code CLI process, including graceful shutdown and atexit cleanup.
#_kill_active_children
def _kill_active_children()atexit handler: SIGTERM all tracked child processes.
#find_binary
def find_binary(binary: str | None=None) -> strLocate the claude CLI binary.
Args:
binary: Explicit path to claude binary. If None, searches PATH.
Returns:
- Absolute path to the claude binary.
Raises:
FileNotFoundError: If claude is not found.
#_version_lt
def _version_lt(a: str, b: str) -> boolReturn True if version a < version b (semver comparison).
#check_version
async def check_version(binary: str, *, timeout: float=2.0) -> str | NoneCheck claude CLI version. Logs warning if below minimum. Returns version string or None.
#ProcessConfig
Configuration for spawning a Claude Code subprocess.
#build_argv
def build_argv(self) -> list[str]Build the full command-line argument list from the flag registry.
#ProcessManager
Manages a Claude Code subprocess lifecycle.
#stdin
def stdin(self) -> asyncio.StreamWriter#stdout
def stdout(self) -> asyncio.StreamReader#is_alive
def is_alive(self) -> bool#stderr_lines
def stderr_lines(self) -> list[str]#_drain_stderr
async def _drain_stderr(self) -> NoneRead stderr line-by-line to prevent pipe buffer deadlock.
#start
async def start(self) -> NoneSpawn the claude subprocess.
#close
async def close(self) -> NoneGraceful shutdown: close stdin -> wait -> SIGTERM -> wait -> SIGKILL.
#kill
async def kill(self) -> NoneImmediate kill.