Does the Rust standard library offer functions/macros for reliably obtaining file descriptors to the stdin, stdout, and stderr streams? Ordinarily, I would just use printf!()
and so on, but in my case, I'm working with environments where stdout may not necessarily be 1, for example.
You can then use the RawFD or RawHandle traits to get the appropriate handler
I'm not sure I understand. By definition, stdin, stdout, and stderr are file descriptors 0, 1, and 2, respectively. std::io::stdin()
, for example, always returns an object that uses file descriptor 0.
At a guess, is it that you want to be able to read and write from a console, regardless of if the standard IO FDs have been remapped?