Windows support — Phase 1: ConPTY backend + un-gate terminal - #11
Merged
Conversation
Phase 1 of Windows support. Add a pseudoconsole (ConPTY) backend to the
pty crate behind the same Pty API the Unix pty pair exposes, and drop the
#![cfg(unix)] gates from pty and terminal so both build on Windows.
- pty splits by target: rustix on Unix, the windows crate on Windows.
windows/{conpty,spawn,mod}.rs wire two anonymous pipes to an HPCON,
spawn the child via CreateProcessW + PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE,
and drive read/write/resize/kill/wait through it.
- default_shell() resolves %COMSPEC%/cmd.exe on Windows.
- Winsize::to_termios stays Unix-only.
Verified: cargo check --target x86_64-pc-windows-gnu for pty + terminal,
and the full Unix test suite (pty 20, terminal 10) still green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 of Windows support (builds on the merged Phase 0 spike). Gives the terminal an actual backend on Windows.
What's here
ptynow has two backends behind onePtyAPI. Deps split by target:rustixon Unix, thewindowscrate on Windows.windows/conpty.rs— creates two anonymous pipes + anHPCON(CreatePseudoConsole/ResizePseudoConsole/ClosePseudoConsole); keeps the input-write and output-read ends.windows/spawn.rs—CreateProcessWwithPROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE+EXTENDED_STARTUPINFO_PRESENT; handle inheritance off; proper command-line quoting and a merged UTF-16 environment block;kill/wait/try_waitover the process handle.windows/mod.rs— thePtytype mirroring the Unix one (spawn/read/write/try_clone_reader/try_clone_writer/resize/child_pid/foreground_running/kill/wait/try_wait).default_shell()resolves%COMSPEC%→cmd.exeon Windows.terminalloses its#![cfg(unix)]gate — the reader thread is allFileI/O, so it's portable as-is.Verification
cargo check --target x86_64-pc-windows-gnupasses forptyandterminal(local cross-check).--workspacebuild clean; clippy clean.terminal::*/pty::*errors inappare resolved;notes,relay, andapp's IPC/titlebar cluster remain for Phases 2–3).Known Windows limitations (documented, deferred)
foreground_running()returnsfalseon Windows (ConPTY has no controlling-terminal foreground-group query) — callers treat it as "not busy".appcompiles (Phase 2).Not in scope
appportability (named-pipe IPC, Windows window chrome),relay, and packaging — Phases 2–4.