I have stumbled on this C code. It uses freopen to reopen stdin in binary mode:
if (!isatty(STDIN_FILENO))
freopen(NULL, "rb", stdin);
I don't understand where the isatty test comes from. Does it mean that it does not make sense to reopen a terminal ?
What would be wrong with omitting the isatty test, leaving
freopen(NULL, "rb", stdin);