Skip to main content

write_stdin_with_timeout

Function write_stdin_with_timeout 

Source
pub fn write_stdin_with_timeout(
    cmd: &mut Command,
    input: Vec<u8>,
    timeout: Duration,
) -> Result<ExitStatus>
Expand description

Feed input to cmd’s stdin and wait for exit under a deadline — the write-side sibling of output_with_timeout. stdout/stderr go to null, so tools that fork a long-lived holder of their fds (wl-copy and xclip serve the selection from a background fork) can’t pin any pipe of ours.

stdin is fed from a background thread: a child that never reads can’t block the caller, and dropping the handle after the write delivers EOF. A write against a dead child (EPIPE) is ignored — the exit status or the timeout already tells that story.