Fix for sleep issue in bash loadable builtins
Replaced select() with pselect() and Blocked the
SIGCHLD signal with sigprocmask() during the sleep process.
Signed-off-by: Thiruvadi Rajaraman
Index: bash-4.2/lib/sh/ufuncs.c
===================================================================
--- bash-4.2.orig/lib/sh/ufuncs.c 2009-01-08 19:30:47.000000000 +0530
+++ bash-4.2/lib/sh/ufuncs.c 2017-12-04 15:53:09.576891443 +0530
@@ -19,7 +19,7 @@
*/
#include "config.h"
-
+#include
#include "bashtypes.h"
#if defined (TIME_WITH_SYS_TIME)
@@ -86,11 +86,20 @@
unsigned int sec, usec;
{
struct timeval tv;
+ sigset_t nmask, omask;
+ int ret;
+
+ sigemptyset(&nmask);
+ sigaddset(&nmask, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &nmask, &omask);
tv.tv_sec = sec;
tv.tv_usec = usec;
- return select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tv);
+ ret = pselect(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tv, &nmask);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
+
+ return ret;
}
#else /* !HAVE_TIMEVAL || !HAVE_SELECT */
int