How does "less" command get stdin input?

view story

http://stackoverflow.com – 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. (HowTos)