libbb: introduce and use nonblock_safe_read(). Yay!

Our shells are immune from this nasty O_NONBLOCK now!

function                                             old     new   delta
nonblock_safe_read                                     -      78     +78
file_get                                             276     295     +19
generateMTFValues                                    428     435      +7
read_line_input                                     1776    1772      -4
preadbuffer                                          543     450     -93
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 104/-97)             Total: 7 bytes
   text    data     bss     dec     hex filename
 615190     715   23924  639829   9c355 busybox_old
 615168     715   23924  639807   9c33f busybox_unstripped
This commit is contained in:
Denis Vlasenko
2008-02-20 22:23:24 +00:00
parent ae86a338b8
commit e376d454bb
6 changed files with 75 additions and 15 deletions

View File

@ -1273,10 +1273,10 @@ static void get_user_input(struct in_str *i)
prompt_str = setup_prompt_string(i->promptmode);
#if ENABLE_FEATURE_EDITING
/* Enable command line editing only while a command line
* is actually being read; otherwise, we'll end up bequeathing
* atexit() handlers and other unwanted stuff to our
* child processes (rob@sysgo.de) */
r = read_line_input(prompt_str, user_input_buf, BUFSIZ-1, line_input_state);
* is actually being read */
do {
r = read_line_input(prompt_str, user_input_buf, BUFSIZ-1, line_input_state);
} while (r == 0); /* repeat if Ctrl-C */
i->eof_flag = (r < 0);
if (i->eof_flag) { /* EOF/error detected */
user_input_buf[0] = EOF; /* yes, it will be truncated, it's ok */