1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-24 15:04:13 +00:00
cde/src/cmd/ksh93/sh
Johnothan King 2db9953ae0
Fix three bugs in the sleep builtin (#77)
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
2020-07-17 05:00:28 +01:00
..
args.c Fix process substitution combined with redirection (#40) 2020-06-23 23:02:16 +01:00
arith.c silence macro redefinition warnings (re: 7003aba4) 2020-06-16 04:51:21 +02:00
array.c Fix crashes caused by 'typeset -RF' (#47) 2020-06-28 23:30:27 +01:00
bash.c Fix 47 typos in user-facing help and error messages 2020-06-12 01:45:12 +02:00
defs.c Fix 'test'/'[' exit status >1 on error in arithmetic expression 2020-06-12 01:45:15 +02:00
deparse.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
env.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
expand.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
fault.c Fix a fork bomb when vi is run from a script and sent Ctrl-Z (#73) 2020-07-13 19:10:23 +01:00
fcin.c Fix parsing of multibyte characters 2020-06-12 01:45:17 +02:00
init.c Make the 'history' and 'r' commands builtins (#76) 2020-07-16 18:56:49 +01:00
io.c Fix possible crash due to failure to update shell FD state 2020-07-10 20:04:31 +01:00
jobs.c Fix three bugs in the sleep builtin (#77) 2020-07-17 05:00:28 +01:00
lex.c Fix ERE repetition expressions in [[ ... =~ ERE{x,y} ]] (#54) 2020-07-02 18:40:15 +01:00
macro.c POSIX compliance fix: apply 'set -u' to $! 2020-06-12 01:45:17 +02:00
main.c Make the 'history' and 'r' commands builtins (#76) 2020-07-16 18:56:49 +01:00
name.c Fix memory leak on unset of associative array (#64) 2020-07-09 01:09:40 +01:00
nvdisc.c Fix crashes caused by 'typeset -RF' (#47) 2020-06-28 23:30:27 +01:00
nvtree.c Fix memory corruption when a compound variable is unset (#49) 2020-06-29 18:08:28 +01:00
nvtype.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
parse.c Convert default typeset aliases to regular builtins 2020-07-15 20:54:06 +01:00
path.c Fix hash table memory leak when restoring PATH 2020-07-09 18:34:15 +01:00
pmain.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
shcomp.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
streval.c silence macro redefinition warnings (re: 7003aba4) 2020-06-16 04:51:21 +02:00
string.c shellquoting: rm redundant iswprint() call (re: f9d28935) 2020-07-16 01:13:59 +01:00
subshell.c Fix possible crash due to failure to update shell FD state 2020-07-10 20:04:31 +01:00
suid_exec.c Fix 39 spelling errors and a formatting issue 2020-06-12 01:45:18 +02:00
tdump.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
timers.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
trestore.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
waitevent.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
xec.c Fix three bugs in the sleep builtin (#77) 2020-07-17 05:00:28 +01:00