claudestream v0.14.2 /claudestream._process
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

python
def _kill_active_children()

atexit handler: SIGTERM all tracked child processes.

#find_binary

python
def find_binary(binary: str | None=None) -> str

Locate 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

python
def _version_lt(a: str, b: str) -> bool

Return True if version a < version b (semver comparison).

#check_version

python
async def check_version(binary: str, *, timeout: float=2.0) -> str | None

Check claude CLI version. Logs warning if below minimum. Returns version string or None.

#ProcessConfig

Configuration for spawning a Claude Code subprocess.

#build_argv

python
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

python
def stdin(self) -> asyncio.StreamWriter

#stdout

python
def stdout(self) -> asyncio.StreamReader

#is_alive

python
def is_alive(self) -> bool

#stderr_lines

python
def stderr_lines(self) -> list[str]

#_drain_stderr

python
async def _drain_stderr(self) -> None

Read stderr line-by-line to prevent pipe buffer deadlock.

#start

python
async def start(self) -> None

Spawn the claude subprocess.

#close

python
async def close(self) -> None

Graceful shutdown: close stdin -> wait -> SIGTERM -> wait -> SIGKILL.

#kill

python
async def kill(self) -> None

Immediate kill.

Search