ash: optional sleep builtin

function                                             old     new   delta
sleepcmd                                               -      10     +10
builtintab                                           352     360      +8
.rodata                                           105264  105271      +7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 25/0)               Total: 25 bytes

Signed-off-by: Shawn Landden <shawnlandden@tutanota.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Shawn Landden 2022-08-27 19:56:21 +02:00 committed by Denys Vlasenko
parent d432049f28
commit 58598eb709
4 changed files with 19 additions and 0 deletions

View file

@ -76,6 +76,12 @@ 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)
*/
do {
errno = 0;
nanosleep(&ts, &ts);