Closes issue #86 and issue #100

Fallback to using stdout, and, when both stdin
and stdout are *both* closed, catch ValueError
and use the same constants as when the attached
process is not a terminal.