bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash: sleep execution issue with bash loadable builtins


From: Ángel
Subject: Re: Bash: sleep execution issue with bash loadable builtins
Date: Mon, 27 Nov 2017 23:47:43 +0100

On 2017-11-27 at 17:47 +0530, Thiruvadi Rajaraman wrote:
> Reproducible test case and Console logs:
> ========================================

Simpler test case:
bash-4.4-rc1# cd examples/loadables/
bash-4.4-rc1/examples/loadables# enable -f ./sleep sleep
bash-4.4-rc1/examples/loadables# sleep 1 & time sleep 10                        
[1] 8892

real    0m1.005s
user    0m0.001s
sys     0m0.004s
[1]+  Done                    sleep 1




> 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

I guess the line 
+  } while ( (ret == -1));
should actually be while ( (ret == -1) && (errno == EINTR) );  ?


Also there's the issue that select() _may_ modify the object pointed to
by the timeout argument [POSIX]. But it may not, in which case this
would end up oversleeping.

On such system, doing eg.
 sleep 9 & time sleep 10

would end up sleeping 19 seconds.       

The solution is probably to change that select() into a pselect() that
masks SIGCHLD (as well as _some_ other signals, but not SIGINT).

Best regards




reply via email to

[Prev in Thread] Current Thread [Next in Thread]