feat(tty-local): implement PTY mode — three-thread bridge, PtyControl, REQ-TTY-02, ADR-056 kill guard
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.
This commit is contained in:
1 parent
42643be338
commit
9f8d07fc25
3 files changed
+739
-87
No files matched your search
@@ -11,12 +11,19 @@ name = "alknet_tty_local"
|
||||
|
||||
[dependencies]
|
||||
alknet-tty = { path = "../alknet-tty" }
|
||||
portable-pty = "0.8"
|
||||
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"
|
||||
libc = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1", features = ["full", "test-util", "macros"] }
|
||||
tokio-stream = "0.1"
|
||||
serde_json = "1"
|
||||
tempfile = "3"
|
||||
Reference in new issue
Block a user