pub unsafe fn take_stdin() -> OwnedFd
Expand description

STDIN_FILENO—Standard input, owned.

This is similar to stdin, however it returns an OwnedFd which closes standard input when it is dropped.

Safety

This is unsafe for the same reasons as stdin.

Other hazards

This has the same hazards as stdin.

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