Expand description
Cross-platform controlling-terminal reattachment.
AD-003/AD-004/AD-005/AD-016 (per HINT-001 — implement before pipeline.rs):
- Open the controlling terminal (
/dev/ttyon Unix,CONIN$/CONOUT$on Windows) so the spawned editor’s stdin/stdout/stderr point at the real terminal — not the pipeline’s pipe stdin/stdout. - Preserve the process’s original stdout sink via
dup(2)(Unix) /DuplicateHandle(Windows) so the post-edit bytes have a route back to the downstream consumer. - On open failure (no controlling terminal — CI, cron, headless Docker),
return
Error::NoControllingTtyso the caller can fail fast (FR-015).
Structs§
- Preserved
Stdout - Snapshot of the original stdout sink, preserved BEFORE the editor’s reattachment so post-edit bytes can route back to the pipeline.
- TtyHandles
- File handles for the controlling terminal that the spawned editor child
will inherit. On Unix these wrap the file descriptors for
/dev/ttyopened twice (read + write); on Windows they wrapCONIN$andCONOUT$.
Functions§
- open_
controlling_ tty - Open the controlling terminal for read+write. Unix uses
/dev/tty; Windows usesCONIN$/CONOUT$viaCreateFileW. - preserve_
stdout - Preserve the process’s current stdout sink via platform-specific duplication, so reopening stdout to the TTY does not clobber the path back to the pipeline.