# Function rustix::io::stderr

source · [−]

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

Expand description

`STDERR_FILENO`—Standard error, borrowed.

## Safety

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

The stderr 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

Stderr could be redirected to arbitrary output sinks, and unless one knows how the process’ standard error is being used, one could unexpectedly inject bytes into a stream being written by another part of the process.

## References

- POSIX
- Linux