Function rustix::io::stdout

source · []
pub unsafe fn stdout() -> BorrowedFd<'static>
Expand description

STDOUT_FILENO—Standard output, borrowed.

Safety

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

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

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

References