If I run, for example, ifconfig | less
, the less
program manages to at the same time:
- Capture output of
ifconfig
through the standard input where the output ofifconfig
is piped - 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?
CodePudding user response:
It reads keyboard input from /dev/tty
instead of from stdin.