When I try something like

php -i | less

Less is not responding to hotkeys, but prints them like pressing "q" results in statusline




Pressing ENTER like "executes" the keycode and less perfoems the action.

Piping trivial small stuff work however...

OS: Fedora 14

1 Answer 1


php -i is doing something weird with stdin. Try this:

php -i </dev/null | less
  • Actually, it's less that does the "something weird". It changes to non-canonical mode input processing. Of course php may well be doing something as well, but this is simply a specific case of the more general don't have two programs simultaneously interacting with the terminal that employ different terminal input modes and expect things to work.
    – JdeBP
    Mar 17, 2011 at 20:29
  • @JdeBP: less may very well be doing something weird, but this is from strace php -i without less: ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 Mar 17, 2011 at 21:00
  • Setting canonical mode input processing (icanon) is not "something weird". Canonical mode is the norm. Hence its name.
    – JdeBP
    Mar 18, 2011 at 13:44
  • 1
    @JdeBP: Well, I don't know what's hidden behind the ... and perhaps the clue lies elsewhere. But why is php -i opening stdin at all? It does this same odd behavior with more (which is not a symlink or alias on my system), but, interestingly, not pg or (inconsistently) most. PHP also does this with php -r 'for ($i = 1; $i <= 100; $i++) { print "$i\n"; }' | less. AWK, Perl, Python, etc., don't exhibit this weirdness. Conclusion: PHP is broken. Mar 18, 2011 at 14:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .