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>
This commit is contained in:
parent
d661cb1977
commit
ce839dea92
@ -76,16 +76,14 @@ void FAST_FUNC sleep_for_duration(duration_t duration)
|
|||||||
ts.tv_sec = duration;
|
ts.tv_sec = duration;
|
||||||
ts.tv_nsec = (duration - ts.tv_sec) * 1000000000;
|
ts.tv_nsec = (duration - ts.tv_sec) * 1000000000;
|
||||||
}
|
}
|
||||||
/* NB: if ENABLE_ASH_SLEEP, we end up here if "sleep N"
|
/* NB: ENABLE_ASH_SLEEP requires that we do NOT loop on EINTR here:
|
||||||
* is run in ash. ^C will still work, because ash's signal handler
|
* otherwise, traps won't execute until we finish looping.
|
||||||
* does not return (it longjumps), the below loop
|
|
||||||
* will not continue looping.
|
|
||||||
* (This wouldn't work in hush)
|
|
||||||
*/
|
*/
|
||||||
do {
|
//do {
|
||||||
errno = 0;
|
// errno = 0;
|
||||||
nanosleep(&ts, &ts);
|
// nanosleep(&ts, &ts);
|
||||||
} while (errno == EINTR);
|
//} while (errno == EINTR);
|
||||||
|
nanosleep(&ts, &ts);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
duration_t FAST_FUNC parse_duration_str(char *str)
|
duration_t FAST_FUNC parse_duration_str(char *str)
|
||||||
|
Loading…
Reference in New Issue
Block a user