ksh hangs on certain combination of subshells, pipes and redirections
Issue
Simple combination of subshells, pipes and redirections leads to ksh hang.
Reproducer on RHEL 6 (ksh-20100621-16.el6):
#!/bin/ksh
RC=`( head -c 118785 /dev/zero | wc -c ) 2>&1`
For 118784 script doesn't hang, for 118785 does.
From strace in 118784 case it seems, that wc is executed after the head's STDOUT is closed.
In 118785 case head process is waiting at he attempt to write \0 to STDOUT, no wc process is spawned yet.
Reproducer on f17 (ksh-20120229-2.fc17.x86_64):
#!/bin/ksh
RC=`( head -c 1 /dev/zero | ( wc -c ) 2>&1 ) 2>&1`
the script hangs after both children exits with exitcode 0.
On rhel5 those scripts doesn't hang.
The above reproducers are stripped down from following script:
#!/bin/ksh
ct=118500
step=1
while true
do
exec 3>&1
RC=`( head -c $ct /dev/zero | (wc -c ; echo $? >&4 ) 1>&3) 4>&1`
ct=`expr $ct + $step`
done
Environment
- Red Hat Enterprise Linux (RHEL) 6.1
- Fedora 17
- ksh-20100621-16.el6
- ksh-20120229-2.fc17.x86_64
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
