← Commit list

7362d2979

Denys Vlasenko
Denys Vlasenko
2023-04-10
SUCCESS Duration: 157s

Subject

ash: fix sleep built-in not running INT trap immediately on ^C

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/duration.c+7 -9
@@ -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)