Skip to main content

spawn_reader

Function spawn_reader 

Source
pub fn spawn_reader(
    reader: Box<dyn Read + Send>,
    snapshot: Arc<ArcSwap<TerminalSnapshot>>,
    rows: u16,
    cols: u16,
    scrollback_lines: u32,
    paint_request: Option<Arc<Notify>>,
    writer: Arc<Mutex<Box<dyn Write + Send>>>,
) -> SharedTerm
Expand description

Spawn the reader task on a detached OS thread. Returns the SharedTerm handle the caller stores alongside the snapshot so dispatch-time operations (scroll, resize) can reach into the alacritty Term.

2026-05-25: dropped the tokio::task::JoinHandle<()> return + the abort_handle on TerminalBuffer. Reason: tokio’s Runtime::Drop for the editor actor’s current_thread runtime waits for in-flight blocking tasks to complete before finishing — and a PTY reader blocked on read(&mut buf) only returns once the child closes its slave fd. That waiter was the real cause of the :q freeze: even with SIGKILL firing from TerminalBuffer::Drop, the kernel takes some time to deliver the signal + reap the child, and the runtime drop wouldn’t proceed until then. A plain std::thread detaches the reader from any runtime: the editor can exit at its own pace; the OS reclaims the thread on process teardown.