I was bitten by this recentishly and I had to learn the difference between file descriptors and descriptions. I had a program that was misbehaving when talking to a tty, but not when the output was piped through cat. Turns the program would set O_NONBLOCK (a description level property) on its input, but of course the shell was dup'ing the input tty fd to output as well, implicitly making the output non-blocking as well. Setting the output to a different description (i.e. the pipe) would workaround that.