#[cfg(unix)] mod unix; #[cfg(unix)] pub(crate) use unix::*; #[cfg(windows)] use portable_pty::{native_pty_system, Child, CommandBuilder, MasterPty, PtySize}; #[cfg(windows)] pub(crate) struct SpawnedPty { pub master: Box, pub child: Box, } #[cfg(windows)] pub(crate) fn spawn_with_portable_pty( rows: u16, cols: u16, cmd: CommandBuilder, ) -> std::io::Result { let pty_system = native_pty_system(); let pair = pty_system .openpty(PtySize { rows, cols, pixel_width: 0, pixel_height: 0, }) .map_err(|err| std::io::Error::other(err.to_string()))?; let child = pair .slave .spawn_command(cmd) .map_err(|err| std::io::Error::other(err.to_string()))?; Ok(SpawnedPty { master: pair.master, child, }) }