INNER CODE UNIT · Rust

native_pty_system

psmux/psmux · crates/portable-pty-psmux/src/lib.rs:419

pub fn native_pty_system() -> Box<dyn PtySystem + Send> {
    Box::new(NativePtySystem::default())
}

/// The one process-global lock that orders console identity changes against
/// ConPTY spawns.
///
/// On Windows, FreeConsole/AttachConsole swap the whole process's console
/// connection and its std handle slots.  CreateProcessW for a ConPTY child
/// (bInheritHandles=FALSE, no STARTF_USESTDHANDLES) stamps the parent's
/// std handle *values* into the child's ProcessParameters at that instant;
/// a spawn landing inside another thread's FreeConsole/AttachConsole window
/// gives the child freed, recycled handle values and the shell dies at its
/// first console read (psmux issue #450).  Every FreeConsole/AttachConsole
/// dance and every ConPTY spawn must hold this lock.
///
/// Identity changes take it EXCLUSIVELY ([`console_state_lock`]); spawns take
/// it SHARED ([`conpty_spawn_guard`]).  See `conpty_spawn_guard` for why two

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…