diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-04-10 17:30:27 +0300 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-04-25 17:47:22 +0300 |
commit | ce839dea92ce10627094096835e831bf5d267631 (patch) | |
tree | 333fbe64830fac7de902f0a521f29b6b1c2ec789 /libbb | |
parent | d661cb1977def8215c50ae3eed1f9beb2877b862 (diff) |
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 <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/duration.c | 16 |
1 files changed, 7 insertions, 9 deletions
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) |