# Function rustix::io::stdin

source · [−]

    pub const unsafe fn stdin() -> BorrowedFd<'static>

Expand description

`STDIN_FILENO`—Standard input, borrowed.

## Safety

This function must be called from code which knows how the process’ standard input is being used. Often, this will be the `main` function or code that knows its relationship with the `main` function.

The stdin file descriptor can be closed, potentially on other threads, in which case the file descriptor index value could be dynamically reused for other purposes, potentially on different threads.

## Other hazards

Stdin could be redirected from arbitrary input sources, and unless one knows how the process’ standard input is being used, one could consume bytes that are expected to be consumed by other parts of the process.

## References

- POSIX
- Linux