Implement allocate_pty in src/pty.rs: portable_pty openpty + spawn as session leader (set_controlling_tty(true)), with the three-thread blocking→async bridge (REQ-TTY-01): reader → mpsc<Bytes> with zero-length EOF sentinel, writer draining mpsc<StdinCmd> (Bytes/Eof), waiter → oneshot<i32>. TtyHandle.stdout is ReceiverStream<Bytes>, stdin is a StdinSink AsyncWrite wrapper over mpsc::Sender<StdinCmd> (parks a reserve+send future when the channel is full), stderr is None (PTY merges), exit_code is LocalExitFuture. PtyControl implements TtyControl: resize via MasterPty::resize; signal via libc::kill(-pgid, sig) with kill(pid, sig) fallback (Unix, REQ-TTY-02) using alknet_tty::signal_from_name; unknown names and non-Unix fall back to ChildKiller::kill (SIGHUP). LocalExitFuture wraps the oneshot::Receiver<i32> + a ChildKiller kill guard (ADR-056). poll delegates to the receiver and disarms the guard on Ready (no-op Drop on happy path); Drop on cancel calls ChildKiller::kill (SIGHUP) — best-effort; the waiter thread reaps. Bump portable-pty 0.8 → 0.9 to match the POC API (MasterPty: Send). Add tokio-stream, serde_json (dev), tempfile (dev) deps. Tests: happy path (echo), stdin round-trip (cat), resize, signal INT kills child, signal reaches process group (bash -c "sleep 60"), cancel cleanup on drop, unknown signal falls back to ChildKiller.
29 lines
711 B
TOML
29 lines
711 B
TOML
[package]
|
|
name = "alknet-tty-local"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
description = "Local TTY backend for alknet-tty: LocalTtyBackend via portable_pty (PTY mode) and std::process::Command (pipe/runner mode)"
|
|
repository.workspace = true
|
|
|
|
[lib]
|
|
name = "alknet_tty_local"
|
|
|
|
[dependencies]
|
|
alknet-tty = { path = "../alknet-tty" }
|
|
portable-pty = "0.9"
|
|
tokio = { version = "1", features = ["full"] }
|
|
tokio-stream = "0.1"
|
|
bytes = "1"
|
|
futures-core = "0.3"
|
|
tracing = "0.1"
|
|
thiserror = "2"
|
|
|
|
[target.'cfg(unix)'.dependencies]
|
|
libc = "0.2"
|
|
|
|
[dev-dependencies]
|
|
tokio = { version = "1", features = ["full", "test-util", "macros"] }
|
|
tokio-stream = "0.1"
|
|
serde_json = "1"
|
|
tempfile = "3" |