0

If I run, for example, ifconfig | less, the less program manages to at the same time:

  1. Capture output of ifconfig through the standard input where the output of ifconfig is piped
  2. React to user's keyboard input and be interactive

I never gave this much thought, but as I tried to write a program with functionality similar to less, I got confused: how does it manage to do both at the same time, and what does it do to implement 2, as it's clearly not the standard input?

Max Yankov
  • 12,551
  • 12
  • 67
  • 135
  • See this [question](https://stackoverflow.com/questions/43947363/detect-if-a-command-is-piped-or-not) for a solution in Go. It will be similar in other languages. – Matt Jun 21 '22 at 00:12

1 Answers1

1

It reads keyboard input from /dev/tty instead of from stdin.