lineedit: fix rare SEGV; mark a few FIXMEs
Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
ea137aa931
commit
232ebaa568
@ -41,6 +41,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
#include "unicode.h"
|
#include "unicode.h"
|
||||||
|
#ifndef _POSIX_VDISABLE
|
||||||
|
# define _POSIX_VDISABLE '\0'
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
# define ENABLE_FEATURE_EDITING 0
|
# define ENABLE_FEATURE_EDITING 0
|
||||||
@ -184,6 +188,7 @@ extern struct lineedit_statics *const lineedit_ptr_to_statics;
|
|||||||
IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \
|
IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \
|
||||||
IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \
|
IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static void deinit_S(void)
|
static void deinit_S(void)
|
||||||
{
|
{
|
||||||
#if ENABLE_FEATURE_EDITING_FANCY_PROMPT
|
#if ENABLE_FEATURE_EDITING_FANCY_PROMPT
|
||||||
@ -1676,7 +1681,7 @@ static void ask_terminal(void)
|
|||||||
* write(1, "~/srcdevel/bbox/fix/busybox.t4 # ", 33) = 33
|
* write(1, "~/srcdevel/bbox/fix/busybox.t4 # ", 33) = 33
|
||||||
* poll([{fd=0, events=POLLIN}], 1, 0) = 0 (Timeout) <-- no input exists
|
* poll([{fd=0, events=POLLIN}], 1, 0) = 0 (Timeout) <-- no input exists
|
||||||
* write(1, "\33[6n", 4) = 4 <-- send the ESC sequence, quick!
|
* write(1, "\33[6n", 4) = 4 <-- send the ESC sequence, quick!
|
||||||
* poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}])
|
* poll([{fd=0, events=POLLIN}], 1, -1) = 1 ([{fd=0, revents=POLLIN}])
|
||||||
* read(0, "\n", 1) = 1 <-- oh crap, user's input got in first
|
* read(0, "\n", 1) = 1 <-- oh crap, user's input got in first
|
||||||
*/
|
*/
|
||||||
struct pollfd pfd;
|
struct pollfd pfd;
|
||||||
@ -1834,10 +1839,11 @@ static void win_changed(int nsig)
|
|||||||
{
|
{
|
||||||
int sv_errno = errno;
|
int sv_errno = errno;
|
||||||
unsigned width;
|
unsigned width;
|
||||||
|
|
||||||
get_terminal_width_height(0, &width, NULL);
|
get_terminal_width_height(0, &width, NULL);
|
||||||
cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
|
//FIXME: cmdedit_setwidth() -> redraw() -> printf() -> KABOOM! (we are in signal handler!)
|
||||||
if (nsig == SIGWINCH)
|
cmdedit_setwidth(width, /*redraw_flg:*/ nsig);
|
||||||
signal(SIGWINCH, win_changed); /* rearm ourself */
|
|
||||||
errno = sv_errno;
|
errno = sv_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2016,14 +2022,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
|
|||||||
new_settings.c_cc[VMIN] = 1;
|
new_settings.c_cc[VMIN] = 1;
|
||||||
new_settings.c_cc[VTIME] = 0;
|
new_settings.c_cc[VTIME] = 0;
|
||||||
/* Turn off CTRL-C, so we can trap it */
|
/* Turn off CTRL-C, so we can trap it */
|
||||||
#ifndef _POSIX_VDISABLE
|
|
||||||
# define _POSIX_VDISABLE '\0'
|
|
||||||
#endif
|
|
||||||
new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
|
new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
|
||||||
tcsetattr_stdin_TCSANOW(&new_settings);
|
tcsetattr_stdin_TCSANOW(&new_settings);
|
||||||
|
|
||||||
previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
|
|
||||||
win_changed(0); /* do initial resizing */
|
|
||||||
#if ENABLE_USERNAME_OR_HOMEDIR
|
#if ENABLE_USERNAME_OR_HOMEDIR
|
||||||
{
|
{
|
||||||
struct passwd *entry;
|
struct passwd *entry;
|
||||||
@ -2046,6 +2047,11 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
|
|||||||
parse_and_put_prompt(prompt);
|
parse_and_put_prompt(prompt);
|
||||||
ask_terminal();
|
ask_terminal();
|
||||||
|
|
||||||
|
/* Install window resize handler (NB: after *all* init is complete) */
|
||||||
|
//FIXME: save entire sigaction!
|
||||||
|
previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
|
||||||
|
win_changed(0); /* get initial window size */
|
||||||
|
|
||||||
read_key_buffer[0] = 0;
|
read_key_buffer[0] = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user