In `flisten` check that the stream is not in an error state, as well as not eof
This patch is inspired by the issue I described here: https://groups.google.com/d/msg/sage-devel/y79rSTdBLQA/LnkO66FCAwAJ
But in short, there are situations (such as a hangup) where reading/writing to stdio will result in an error. If, at this point, the LISP debugger is entered it tries to call
(clear-input), which in turn calls
flisten in a loop. However, it only checks for
EOF, and not for errors.
This isn't a problem on Linux (it seems), because
getc sets the EOF indicator on the stream. However, this is not a requirement, and on some platforms it seems (particularly Cygwin, which uses the newlib C library) only set the error indicator but not EOF. This results in an infinite loop. The simplest solution seems to be to just check
ferror here as well.