Skip to main content

Module tty

Module tty 

Source
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/tty on 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::NoControllingTty so the caller can fail fast (FR-015).

Structs§

PreservedStdout
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/tty opened twice (read + write); on Windows they wrap CONIN$ and CONOUT$.

Functions§

open_controlling_tty
Open the controlling terminal for read+write. Unix uses /dev/tty; Windows uses CONIN$/CONOUT$ via CreateFileW.
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.