Skip to main content

pty_window

Function pty_window 

Source
pub fn pty_window(
    master: &Fd,
    rows: u16,
    cols: u16,
) -> Result<(u16, u16), CoreError>
Expand description

Apply an initial window size to a pty master before the child execs and read back the actual winsize the kernel holds.

This is the single source of truth for the pty’s starting geometry: callers that need LINES/COLUMNS in the child environment must derive them from the returned (rows, cols) — the TIOCGWINSZ read-back — not from the values they passed in. Two writers of the same fact (the wire dims and a separate TIOCSWINSZ) can drift the moment one call site changes; the read-back keeps the env provably consistent with what the kernel/pty layer believes.

§Errors

  • EINVAL: rows or cols is zero.
  • ENOTTY: master is not a terminal.