Skip to main content

Module shell

Module shell 

Source
Expand description

A ShellBackend implementation for local processes.

Originates from the same inline tokio::process::Command flow historically used in the bash tool, but moves process management, buffered reads, and exit synchronization into the backend layer so that BashTool interacts only through the ShellBackend trait — a local shell execution backend.

Internal data structures:

  • LocalShellBackend.terminals: Mutex<HashMap<TerminalId, Arc<TerminalState>>> Global terminal table.
  • TerminalState holds the output buffer, exit status, exit_notify, and kill_notify.
  • Each terminal spawns a reader task: blocks reading stdout/stderr → writes into buffer → waits on kill_notify or both EOFs → calls child.wait() → writes exit → calls notify_waiters(). The child is exclusively owned by the reader task to avoid lock contention.

Structs§

LocalShellBackend
Local shell backend: each command spawns a sh -c child process, with state managed in the terminals table until release.