I'm working on a small Rust cli project, which involves having to deal with some relatively low level details of how processes interact between them.
In POSIX-compatible systems, shells usually pass their "standard" file descriptors to their child: stdin (0), stdout (1), and stderr(2); and many other non-shell processes do the same as well (and, when they are not inherited from the parent process, it's usually because we have pipes involved).
The problem is that, although the most usual case, that might not hold all the time, and we could have some processes without some of these file descriptors available.
As far as I can see, in Rust we have the method
std::io::stdin that returns as a struct that allows us to "directly" interact with stdin... and it seems it assumes that stdin will be always there (given that it does not return a
Result struct, but directly a
How can we check in a safe way if stdin is really available?