mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
This commit backports the main changes to sh_delay from ksh93v-
and ksh2020, which fixes the following bugs:
- Microsecond amounts of less than one millisecond are no longer
ignored. The following loop will now take a minimum of one
second to complete:
for ((i = 0; i != 10000; i++)) do
sleep PT100U
done
- 'sleep 30' no longer adds an extra 30 milliseconds to the total
amount of time to sleep. This bug is hard to notice since 30
milliseconds can be considered within the margin of error. The
only reason why longer delays weren't affected is because the old
code masked the bug when the interval is greater than 30 seconds:
else if(n > 30)
{
sleep(n);
t -= n;
}
This caused 'sleep -s' to break with intervals greater than 30
seconds, so an actual fix is used instead of a workaround.
- 'sleep -s' now functions correctly with intervals of more than
30 seconds as the new code doesn't need the old workaround. This
is done by handling '-s' in sh_delay.
src/cmd/ksh93/bltins/sleep.c:
- Remove the replacement for sleep(3) from the sleep builtin.
- Replace the old sh_delay function with the newer one from ksh2020.
The new function uses tvsleep, which uses nanosleep(3) internally.
src/cmd/ksh93/include/shell.h,
src/cmd/ksh93/edit/edit.c,
src/cmd/ksh93/sh/jobs.c,
src/cmd/ksh93/sh/xec.c,
src/cmd/ksh93/shell.3:
- Update sh_delay documentation and usage since the function now
requires two arguments.
src/cmd/ksh93/tests/builtins.sh:
- Add a regression test for 'sleep -s' when the interval is greater
than 30 seconds. The other bugs can't be tested for in a feasible
manner across all systems:
https://github.com/ksh93/ksh/pull/72#issuecomment-657215616
|
||
|---|---|---|
| .. | ||
| args.c | ||
| arith.c | ||
| array.c | ||
| bash.c | ||
| defs.c | ||
| deparse.c | ||
| env.c | ||
| expand.c | ||
| fault.c | ||
| fcin.c | ||
| init.c | ||
| io.c | ||
| jobs.c | ||
| lex.c | ||
| macro.c | ||
| main.c | ||
| name.c | ||
| nvdisc.c | ||
| nvtree.c | ||
| nvtype.c | ||
| parse.c | ||
| path.c | ||
| pmain.c | ||
| shcomp.c | ||
| streval.c | ||
| string.c | ||
| subshell.c | ||
| suid_exec.c | ||
| tdump.c | ||
| timers.c | ||
| trestore.c | ||
| waitevent.c | ||
| xec.c | ||