Bug 736195 - Apparent race condition when using pipes in KSH scripts.
Summary: Apparent race condition when using pipes in KSH scripts.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: ksh
Version: 5.7
Hardware: All
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Michal Hlavinka
QA Contact: qe-baseos-tools
URL:
Whiteboard:
: 709774 (view as bug list)
Depends On:
Blocks: 668957 739669
TreeView+ depends on / blocked
 
Reported: 2011-09-07 00:06 UTC by Eric Sammons
Modified: 2019-07-04 08:21 UTC (History)
7 users (show)

Fixed In Version: ksh-20100621-1.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 739669 1243895 1243896 1243897 (view as bug list)
Environment:
Last Closed: 2012-02-21 05:51:07 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0159 normal SHIPPED_LIVE ksh bug fix and enhancement update 2012-02-20 14:53:47 UTC

Description Eric Sammons 2011-09-07 00:06:37 UTC
Description of problem:

When running ksh scripts on RHEL 5 (and RHEL 6) multiple processes are reported running when $(ps -ef |grep $BNAME|grep -v grep |wc -l).  Expect only "1" to be returned but often times see 2+ returned.

[code]
#!/bin/ksh93

BNAME=`basename $0`
OUT="`ps -ef|grep ${BNAME} | grep -v grep |wc -l`"
if [ ${OUT} -ge "2" ];then
   echo "FAIL"
   exit 1
else
   echo "SUCCESS"
fi
[/code]

Version-Release number of selected component (if applicable):
<= ksh-20100202-1.el5_5.1 (RHEL5)
<= ksh-20100621-6.el6.x86_64 (RHEL6)


How reproducible:

Every time, use code snippet above.


Steps to Reproduce:
1. Create a ksh script as noted above.
2. Run script
  
Actual results:
FAIL
(indicating 2+ pids returned)

Expected results:
SUCESS
(indicating 1 pid returned)

Additional info:

RHEL 5.6 (ksh-20100202-1.el5_5.1)
# ./test5.6.ksh 
+ basename ./test5.6.ksh
+ BNAME=test5.6.ksh
+ ps -ef
+ grep test5.6.ksh
+ grep -v grep
+ wc -l
+ OUT=2
+ [ 2 -ge 2 ]
+ echo FAIL
FAIL
+ exit 1

Fedora 15 (ksh-20110505-2.fc15.x86_64)
# ./test.ksh
+ basename ./test.ksh
+ BNAME=test.ksh
+ ps -ef
+ grep test.ksh
+ grep -v grep
+ wc -l
+ OUT=1
+ [ 1 -ge 2 ]
+ echo SUCCESS
SUCCESS

I feel the following patch may have provided the fix; however, I can not get the patch into the RHEL 5 version of ksh.

* Wed Jun 08 2011 Michal Hlavinka <mhlavink@redhat.com> - 20110505-2
- fix: resume of suspended process using pipes does not work (#708909)

Comment 2 Michal Hlavinka 2011-09-09 09:50:51 UTC
> When running ksh scripts on RHEL 5 (and RHEL 6) multiple processes
> are reported running when $(ps -ef |grep $BNAME|grep -v grep |wc -l).  
> Expect only "1" to be returned but often times see 2+ returned.

Are you sure with that? I can reproduce this in RHEL 5, but it works for me in RHEL 6 (both ksh-20100621-6.el6.x86_64 = rhel-6.1 and update-to-be ksh-20100621-9.el6.x86_64).

I've tested all versions I have and it seems fixed between 2010-05-27 (last broken) and 2010-06-21 (first working) which is scheduled as update in rhel 5.8. So please retest RHEL6 version.

Comment 15 Michal Hlavinka 2011-10-25 12:24:29 UTC
*** Bug 709774 has been marked as a duplicate of this bug. ***

Comment 17 errata-xmlrpc 2012-02-21 05:51:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0159.html


Note You need to log in before you can comment on or make changes to this bug.