mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-22 17:22:19 +03:00
in get_key_buffer(), if we fail to get a character over MAX_BUF_SIZE
times in a row, hang up regardless of the value of errno; this fixes a problem where nano doesn't terminate properly under xterm if the user su's to root, runs nano, and then closes the terminal window git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3309 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
1ec74ee30c
commit
9149325400
@ -58,6 +58,12 @@ CVS code -
|
|||||||
set errno to EINVAL as well as return -1 if they fail. This
|
set errno to EINVAL as well as return -1 if they fail. This
|
||||||
matches the manual page. (DLR)
|
matches the manual page. (DLR)
|
||||||
- winio.c:
|
- winio.c:
|
||||||
|
get_key_buffer()
|
||||||
|
- If we fail to get a character over MAX_BUF_SIZE times in a
|
||||||
|
row, hang up regardless of the value of errno. This fixes a
|
||||||
|
problem where nano doesn't terminate properly under xterm if
|
||||||
|
the user su's to root, runs nano, and then closes the terminal
|
||||||
|
window. (DLR, found by John <acocaracha@gmail.com>)
|
||||||
parse_kbinput()
|
parse_kbinput()
|
||||||
- Interpret Shift-Begin, Shift-Delete, Shift-End, Shift-Home,
|
- Interpret Shift-Begin, Shift-Delete, Shift-End, Shift-Home,
|
||||||
Shift-Insert, and Shift-Suspend as Begin, Delete, End, Home,
|
Shift-Insert, and Shift-Suspend as Begin, Delete, End, Home,
|
||||||
|
@ -590,7 +590,7 @@ typedef struct rcoption {
|
|||||||
* counting the blank lines at their ends. */
|
* counting the blank lines at their ends. */
|
||||||
#define MAX_SEARCH_HISTORY 100
|
#define MAX_SEARCH_HISTORY 100
|
||||||
|
|
||||||
/* The maximum number of bytes we read into a buffer at one time. */
|
/* The maximum number of bytes buffered at one time. */
|
||||||
#define MAX_BUF_SIZE 128
|
#define MAX_BUF_SIZE 128
|
||||||
|
|
||||||
#endif /* !NANO_H */
|
#endif /* !NANO_H */
|
||||||
|
12
src/winio.c
12
src/winio.c
@ -122,7 +122,7 @@ void reset_kbinput(void)
|
|||||||
* default keystroke buffer is empty. */
|
* default keystroke buffer is empty. */
|
||||||
void get_key_buffer(WINDOW *win)
|
void get_key_buffer(WINDOW *win)
|
||||||
{
|
{
|
||||||
int input;
|
int input, errcount;
|
||||||
|
|
||||||
/* If the keystroke buffer isn't empty, get out. */
|
/* If the keystroke buffer isn't empty, get out. */
|
||||||
if (key_buffer != NULL)
|
if (key_buffer != NULL)
|
||||||
@ -137,10 +137,16 @@ void get_key_buffer(WINDOW *win)
|
|||||||
* screen updates. */
|
* screen updates. */
|
||||||
doupdate();
|
doupdate();
|
||||||
|
|
||||||
|
errcount = 0;
|
||||||
while ((input = wgetch(win)) == ERR) {
|
while ((input = wgetch(win)) == ERR) {
|
||||||
|
errcount++;
|
||||||
|
|
||||||
/* If errno is EIO, it means that the input source that we were
|
/* If errno is EIO, it means that the input source that we were
|
||||||
* using is gone, so die gracefully. */
|
* using is gone, so die gracefully. If we've failed to get a
|
||||||
if (errno == EIO)
|
* character over MAX_BUF_SIZE times in a row, it can mean the
|
||||||
|
* same thing regardless of the value of errno, so die
|
||||||
|
* gracefully then too. */
|
||||||
|
if (errno == EIO || errcount > MAX_BUF_SIZE)
|
||||||
handle_hupterm(0);
|
handle_hupterm(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user