glibc returs EIO on ttys that are hung up. That's not really correct,
POSIX seems to disagree.
Work around this in our code, and turn this into a clean "1", since a
hung up tty doesn't stop being a tty just because it is hung up.
Background: https://github.com/systemd/systemd/pull/34039
if (isatty(fd))
return true;
+ /* Linux/glibc returns EIO for hung up TTY on isatty(). Which is wrong, the thing doesn't stop being
+ * a TTY after all, just because it is temporarily hung up. Let's work around this here, until this
+ * is fixed in glibc. See: https://sourceware.org/bugzilla/show_bug.cgi?id=32103 */
+ if (errno == EIO)
+ return true;
+
/* Be resilient if we're working on stdio, since they're set up by parent process. */
assert(errno != EBADF || IN_SET(fd, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO));