Background process in ksh command substitution hangs
Issue
Since upgrading ksh93
to ksh-20120801-10.el6_5.3
it is no longer possible to send a process to the background out of a command substitution. Here is how it should work:
# time ksh93 -c 'out=$(/bin/sleep 2 >/dev/null & echo ok); echo $out'
ok
real 0m0.011s
user 0m0.000s
sys 0m0.005s
sleep
is send to background and the whole command immediately returns. This works because the redirection to /dev/null
releases sleep
from the pipe of the command substitution $(...)
. And here is how it behaves with the latest patches (problem still present in ksh-20120801-10.el6_5.4
):
# time ksh93 -c 'out=$(/bin/sleep 2 >/dev/null & echo ok); echo $out'
ok
real 0m2.010s
user 0m0.001s
sys 0m0.005s
sleep
blocks the entire command for the two seconds, which is wrong and breaks scripts.
Environment
- Red Hat Enterprise Linux (RHEL) 6.5
- ksh-20120801-10.el6_5.3
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.