Hacker News new | ask | show | jobs
by xxs 3075 days ago
Redirecting (in simple terms) is setting a file descriptor. So the file descriptor can be tested if it partakes in the input.

A quote for you [0]: Under normal circumstances every UNIX program has three streams opened for it when it starts up, one for input, one for output, and one for printing diagnostic or error messages. These are typically attached to the user's terminal (see tty(4) but might instead refer to files or other devices, depending on what the parent process chose to set up. (See also the "Redirection" section of sh(1).)

[0]: https://linux.die.net/man/3/stdout