less/backport-Fix-bug-related-to-ctrl-X-when-output-is-not-a-termi.patch

44 lines
1.1 KiB
Diff

From ed454a217da417dc052723ea70da8efde0f2e66c Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Sat, 10 Aug 2024 08:11:59 -0700
Subject: [PATCH] Fix bug related to ctrl-X when output is not a terminal.
We should not check for ctrl-X input when the output is not
a terminal. This results in trying to poll and read input
characters from stdin instead of from the terminal.
This problem existed in v661 so is not strictly a regression
that needs to be addressed in the upcoming bug fix release,
but because it's a low-risk fix and has potentially serious
consequences, I'm including it.
Related to #558.
---
os.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/os.c b/os.c
index 61c336c..9f89777 100644
--- a/os.c
+++ b/os.c
@@ -80,6 +80,7 @@ extern int exit_F_on_close;
extern int follow_mode;
extern int scanning_eof;
extern char intr_char;
+extern int is_tty;
#if !MSDOS_COMPILER
extern int tty;
#endif
@@ -237,7 +238,7 @@ start:
}
#endif
#if USE_POLL
- if (fd != tty && use_poll)
+ if (is_tty && fd != tty && use_poll)
{
int ret = check_poll(fd, tty);
if (ret != 0)
--
2.33.0