When fread() came back short with an error, fetch() wrote out what it
had read before looking at errno. If that was the first write to the
output, and the output is a character device that is not a terminal,
such as /dev/null, stdio's check for a terminal left errno set to
ENOTTY. A transfer that timed out was then reported as "Inappropriate
ioctl for device" instead of "transfer timed out", and so was one whose
connection was reset.
Keep the error of the read that failed, and use it both to tell whether
the transfer timed out and in the message.
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")