Constant STDERR

pub const STDERR: BorrowedFd<'static>;

The file descriptor for the standard error stream of the current process.

See [io::stderr()]crate::io::stderr for the higher level handle, which should be preferred whenever possible. However, there are situations where touching the std::io handles (or most other parts of the standard library) risks deadlocks or other subtle bugs. For example:

In these and similar cases, direct access to the file descriptor may be required. However, in most cases, using the std::io handles and accessing the file descriptor via the AsFd implementations is preferable, as it enables cooperation with the standard library's locking and buffering.

I/O safety

This is a BorrowedFd<'static> because the standard input/output/error streams are shared resources that must remain available for the lifetime of the process. This is only true when linking std, and may not always hold for code running before main() or in no_std environments. It is unsound to close these file descriptors. Safe patterns for changing these file descriptors are available on Unix via the StdioExt extension trait.