startup: check stdout instead of stdin when probing for a Linux console

This way we don't have to probe twice, and the result is accurate also
when nano is reading data from standard input.  Standard output should
always be connected to a terminal, as nano is not meant to operate
without a screen.
master
Benno Schulenberg 2020-06-14 10:52:42 +02:00
parent 1c8c02f63b
commit 926bc6751e
1 changed files with 1 additions and 6 deletions

View File

@ -1756,7 +1756,7 @@ int main(int argc, char **argv)
struct vt_stat dummy;
/* Check whether we're running on a Linux console. */
on_a_vt = (ioctl(0, VT_GETSTATE, &dummy) == 0);
on_a_vt = (ioctl(1, VT_GETSTATE, &dummy) == 0);
#endif
/* Back up the terminal settings so that they can be restored. */
@ -2447,11 +2447,6 @@ int main(int argc, char **argv)
}
#endif
#ifdef __linux__
/* Check again whether we're running on a Linux console. */
on_a_vt = (ioctl(0, VT_GETSTATE, &dummy) == 0);
#endif
prepare_for_display();
#ifdef ENABLE_NANORC