Skip to main content

Module blocking

Module blocking 

Source
Available on crate feature blocking only.
Expand description

Blocking pseudoconsole sessions.

Command::spawn creates a managed Session. Choose one of three paths:

All three remain managed and root-bounded. into_parts separates ownership; it does not detach the child or its descendants.

§Service output concurrently

Microsoft’s ConPTY guidance recommends servicing conin and conout on separate threads. Once conout’s pipe buffer fills, the console host and its client can stop making progress. A caller that blocks in Child::wait without another thread draining output can therefore deadlock.

Session::wait and Session::collect_output perform the root wait and output drain together. With Session::into_parts, move OwnedReadHalf to its own reader thread while retaining input, child, and resize/clear control elsewhere.

§Input shutdown ends the session

Dropping OwnedWriteHalf is not the console equivalent of closing a child’s stdin. It closes conin and requests pseudoconsole teardown, which sends a close event to attached clients. Keep input alive until the program exits through its own protocol.

§Output and root completion

Conout is one raw UTF-8/VT byte stream; stdout and stderr are not separate, and this crate does not parse or decode it. Decode across reads because a UTF-8 code point or VT sequence may span chunks.

Root exit bounds the managed session. A registered wait saves the root’s real status and terminates remaining Job members. Released backends then reach EOF naturally. Legacy backends grant a drain grace and request close from a dedicated worker so the same output stream reaches EOF without running a potentially blocking close on the reader thread.

§Examples

use conpty_oxide::blocking::Command;

let status = Command::new("cmd.exe")
    .args(["/c", "exit", "0"])
    .spawn()?
    .wait()?;
assert!(status.success());

Structs§

Child
A running (or finished) root child of a pseudoconsole session.
Command
A command to run inside a pseudoconsole.
OwnedReadHalf
Owned output half returned by Session::into_parts.
OwnedWriteHalf
Owned input half returned by Session::into_parts.
Session
A managed blocking pseudoconsole session.
SessionParts
Independently owned parts of a managed blocking session.