Function rustix::stdio::take_stderr
source · pub unsafe fn take_stderr() -> OwnedFdExpand description
STDERR_FILENO—Standard error, owned.
This is similar to stderr, however it returns an OwnedFd which closes
standard output when it is dropped.
Safety
Safe std-using Rust code is permitted to assume that the stderr file
descriptor is always valid. This function returns an OwnedFd which will
close the stderr file descriptor when dropped.
Other hazards
This has the same hazards as stderr.
And, when the OwnedFd is dropped, subsequent newly created file
descriptors may unknowingly reuse the stderr file descriptor number, which
may break common assumptions, so it should typically only be dropped at the
end of a program when no more file descriptors will be created.