aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-04-10 16:30:27 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-04-10 16:30:27 +0200
commit7362d2979434c565ae70b0ccf9d4b09d7597fb48 (patch)
tree95767040c2e9d5f496b205545e96ff65372b7dc8
parent611729eff386234b09d40780cdcc21fe72f6f8b8 (diff)
downloadbusybox-w32-7362d2979434c565ae70b0ccf9d4b09d7597fb48.tar.gz
busybox-w32-7362d2979434c565ae70b0ccf9d4b09d7597fb48.tar.bz2
busybox-w32-7362d2979434c565ae70b0ccf9d4b09d7597fb48.zip
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>
-rw-r--r--libbb/duration.c16
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)
76 ts.tv_sec = duration; 76 ts.tv_sec = duration;
77 ts.tv_nsec = (duration - ts.tv_sec) * 1000000000; 77 ts.tv_nsec = (duration - ts.tv_sec) * 1000000000;
78 } 78 }
79 /* NB: if ENABLE_ASH_SLEEP, we end up here if "sleep N" 79 /* NB: ENABLE_ASH_SLEEP requires that we do NOT loop on EINTR here:
80 * is run in ash. ^C will still work, because ash's signal handler 80 * otherwise, traps won't execute until we finish looping.
81 * does not return (it longjumps), the below loop
82 * will not continue looping.
83 * (This wouldn't work in hush)
84 */ 81 */
85 do { 82 //do {
86 errno = 0; 83 // errno = 0;
87 nanosleep(&ts, &ts); 84 // nanosleep(&ts, &ts);
88 } while (errno == EINTR); 85 //} while (errno == EINTR);
86 nanosleep(&ts, &ts);
89} 87}
90#else 88#else
91duration_t FAST_FUNC parse_duration_str(char *str) 89duration_t FAST_FUNC parse_duration_str(char *str)