From 7362d2979434c565ae70b0ccf9d4b09d7597fb48 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 10 Apr 2023 16:30:27 +0200 Subject: ash: fix sleep built-in not running INT trap immediately on ^C function old new delta sleep_for_duration 169 149 -20 Signed-off-by: Denys Vlasenko --- libbb/duration.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'libbb') diff --git a/libbb/duration.c b/libbb/duration.c index 793d02f42..0024f1a66 100644 --- a/libbb/duration.c +++ b/libbb/duration.c @@ -76,16 +76,14 @@ void FAST_FUNC sleep_for_duration(duration_t duration) ts.tv_sec = duration; ts.tv_nsec = (duration - ts.tv_sec) * 1000000000; } - /* NB: if ENABLE_ASH_SLEEP, we end up here if "sleep N" - * is run in ash. ^C will still work, because ash's signal handler - * does not return (it longjumps), the below loop - * will not continue looping. - * (This wouldn't work in hush) + /* NB: ENABLE_ASH_SLEEP requires that we do NOT loop on EINTR here: + * otherwise, traps won't execute until we finish looping. */ - do { - errno = 0; - nanosleep(&ts, &ts); - } while (errno == EINTR); + //do { + // errno = 0; + // nanosleep(&ts, &ts); + //} while (errno == EINTR); + nanosleep(&ts, &ts); } #else duration_t FAST_FUNC parse_duration_str(char *str) -- cgit v1.2.3-55-g6feb From 85e4805ae94ce653d8088d6575dc01114cd00bcf Mon Sep 17 00:00:00 2001 From: Tomas Paukrt Date: Sun, 9 Apr 2023 10:18:51 +0200 Subject: appletlib: fix "warning: unused variable applet_no" Signed-off-by: Tomas Paukrt Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index d5335d353..d9cc48423 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -918,7 +918,7 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) # endif # if NUM_APPLETS > 0 -void FAST_FUNC show_usage_if_dash_dash_help(int applet_no, char **argv) +void FAST_FUNC show_usage_if_dash_dash_help(int applet_no UNUSED_PARAM, char **argv) { /* Special case. POSIX says "test --help" * should be no different from e.g. "test --foo". -- cgit v1.2.3-55-g6feb From 853cfe927fd656a2688ac2bfc81c69e1004c44df Mon Sep 17 00:00:00 2001 From: Akos Somfai Date: Mon, 3 Apr 2023 22:52:06 +0200 Subject: lineedit: fix crash when icanon set with -echo When icanon is set with -echo (e.g. ssh from an emacs shell) then S.state will remain null but later it will be deferenced causing ash to crash. Fix: additional check on state. Signed-off-by: Akos Somfai Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libbb') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 625884adf..bdae10914 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -254,7 +254,7 @@ static NOINLINE const char *get_homedir_or_NULL(void) const char *home; # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH - home = state->sh_get_var ? state->sh_get_var("HOME") : getenv("HOME"); + home = state && state->sh_get_var ? state->sh_get_var("HOME") : getenv("HOME"); # else home = getenv("HOME"); # endif @@ -2038,7 +2038,7 @@ static void parse_and_put_prompt(const char *prmt_ptr) if (!cwd_buf) { const char *home; # if EDITING_HAS_sh_get_var - cwd_buf = state->sh_get_var + cwd_buf = state && state->sh_get_var ? xstrdup(state->sh_get_var("PWD")) : xrealloc_getcwd_or_warn(NULL); # else -- cgit v1.2.3-55-g6feb