commit 926bc6751ed06e36c917a4b1253bbfa882e60d7f
parent 1c8c02f63bb0fcb1bf2f3889cc6d122997a94b0c
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 14 Jun 2020 10:52:42 +0200
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.
Diffstat:
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -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