# Function rustix::io::take_stdout

source · [−]

    pub unsafe fn take_stdout() -> OwnedFd

Expand description

`STDOUT_FILENO`—Standard output, owned.

This is similar to `stdout`, however it returns an `OwnedFd` which closes standard output when it is dropped.

## Safety

This is unsafe for the same reasons as `stdout`.

## Other hazards

This has the same hazards as `stdout`.

And, when the `OwnedFd` is dropped, subsequent newly created file descriptors may unknowingly reuse the stdout 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.

## References

- POSIX
- Linux