Vendor ConPtySystem (#7656)

The repo we were depending on is very large and we need very small part
of it.

---------

Co-authored-by: Pavel <pavel@krymets.com>
This commit is contained in:
pakrym-oai
2025-12-09 09:23:51 -08:00
committed by GitHub
parent 2237b701b6
commit 164265bed1
10 changed files with 789 additions and 5 deletions

View File

@@ -7,7 +7,11 @@ use std::sync::Arc;
use std::sync::Mutex as StdMutex;
use std::time::Duration;
#[cfg(windows)]
mod win;
use anyhow::Result;
#[cfg(not(windows))]
use portable_pty::native_pty_system;
use portable_pty::CommandBuilder;
use portable_pty::MasterPty;
@@ -125,6 +129,16 @@ pub struct SpawnedPty {
pub exit_rx: oneshot::Receiver<i32>,
}
#[cfg(windows)]
fn platform_native_pty_system() -> Box<dyn portable_pty::PtySystem + Send> {
Box::new(win::ConPtySystem::default())
}
#[cfg(not(windows))]
fn platform_native_pty_system() -> Box<dyn portable_pty::PtySystem + Send> {
native_pty_system()
}
pub async fn spawn_pty_process(
program: &str,
args: &[String],
@@ -136,7 +150,7 @@ pub async fn spawn_pty_process(
anyhow::bail!("missing program for PTY spawn");
}
let pty_system = native_pty_system();
let pty_system = platform_native_pty_system();
let pair = pty_system.openpty(PtySize {
rows: 24,
cols: 80,