How does "less" command get stdin input?

bash, less-unix, linux, pipe, shell

Solution

`less` command can check both `argc>1` and `stdin` be associated with a file(not a tty).

Problem

I'm just wondering about this problem: if I can use something like "ls -al | less", less should have the ability of waiting for input from stdin. What I expected to happen is after running "less" command, the program hang up and wait for input(as a consequence of calling gets() or something like that.) But why in fact it showed an error message "Missing filename ("less --help" for help)" end exited? Thank you.

Original source

Related problems