Hi, Found a 'sleep' execution issue with bash loadable builtins and has performed the below sleep test on bash-4.4-rc1.
Bash version: 4.4-rc1 Web link: https://ftp.gnu.org/gnu/bash/bash-4.4-rc1.tar.gz Reproducible test case and Console logs: ======================================== bash-4.4-rc1#./bash bash-4.4-rc1# cd examples/loadables/ bash-4.4-rc1/examples/loadables# enable -f ./sleep sleep bash-4.4-rc1/examples/loadables# date; sleep 1 & date; sleep 4; date Mon Nov 27 17:00:01 IST 2017 [1] 5355 Mon Nov 27 17:00:01 IST 2017 Mon Nov 27 17:00:02 IST 2017 --------------> Took 1 Sec only instead of 4 Sec's. [1]+ Done sleep 1 bash-4.4-rc1/examples/loadables# bash-4.4-rc1/examples/loadables# date; sleep 4 & date; sleep 1; date Mon Nov 27 17:00:16 IST 2017 [1] 5386 Mon Nov 27 17:00:16 IST 2017 Mon Nov 27 17:00:17 IST 2017 bash-4.4-rc1/examples/loadables# bash-4.4-rc1/examples/loadables# date; sleep 1 & date; sleep 10; date Mon Nov 27 17:00:29 IST 2017 [1]+ Done sleep 4 [1] 5390 Mon Nov 27 17:00:29 IST 2017 Mon Nov 27 17:00:30 IST 2017 -------------> Took 1 Sec only instead of 10 Sec's. [1]+ Done sleep 1 root@cavium-Vostro-3446 :~/Desktop/bugzilla-CGX/77504/bash-4.4-rc1/examples/loadables# Fix patch: ========== # Attached the fix patch - Fix_for_bash_loadable_builtin_sleep_execution_issue.patch Please kindly review and suggest your comments. Thanks, Thiruvadi Rajaraman
Fix for bash loadable builtins 'sleep' execution failure issue The rootcause of the failure was found with select() execution with time information in fsleep() function in lib/sh/ufunc.c file. The fix patch content resolves the issue. Test logs (After applying patch) ========= # date; sleep 1 & date; sleep 10; date Mon Nov 27 17:25:31 IST 2017 [1] 13173 Mon Nov 27 17:25:31 IST 2017 Mon Nov 27 17:25:41 IST 2017 -----> Took 10 Sec's sleep [1]+ Done sleep 1 # Signed-off-by: Thiruvadi Rajaraman <trajara...@mvista.com> Index: bash-4.4-rc1/lib/sh/ufuncs.c =================================================================== --- bash-4.4-rc1.orig/lib/sh/ufuncs.c 2017-11-27 13:57:18.172796871 +0530 +++ bash-4.4-rc1/lib/sh/ufuncs.c 2017-11-27 17:21:13.622624417 +0530 @@ -90,11 +90,16 @@ unsigned int sec, usec; { struct timeval tv; + int ret = 0; tv.tv_sec = sec; tv.tv_usec = usec; - return select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tv); + do { + ret = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tv); + } while ( (ret == -1)); + + return ret; } #else /* !HAVE_TIMEVAL || !HAVE_SELECT */ int