Skip to main content

poll_for_input

Function poll_for_input 

Source
pub fn poll_for_input(file: &OpenFile, timeout: Duration) -> Result<bool>
Expand description

Polls an open file for input readability with a timeout.

Returns Ok(true) if data is available for reading, Ok(false) if the timeout elapsed without data becoming available.

For regular files, always returns Ok(true) immediately since they’re always “ready” (matching bash behavior where -t has no effect on regular files).

§Arguments

  • file - The open file to poll.
  • timeout - Maximum time to wait. Use Duration::ZERO to check without blocking.

§Errors

Returns an error if polling fails or the file descriptor cannot be borrowed.