ksh command substitution does not work after stdout/stderr closed

Solution Verified - Updated -

Issue

  • User has a tool which after fork() and before execv() call closes the stdout and stderr file descriptors. This causes the execved script written in ksh not working. This behavior can be reproduced by the following simple command:
# ksh -c 'a=`cd;pwd`;echo $a>/tmp/a' >&-;cat /tmp/a
  • On RHEL 6.3 or RHEL 5.10, the command results in the output
# ksh -c 'a=`cd;pwd`;echo $a>/tmp/a' >&-;cat /tmp/a
/root
#

However, on RHEL 6.5, it outputs an empty line.

Environment

  • Red Hat Enterprise Linux (RHEL) 6.5
  • ksh-20120801-10.el6_5.8.x86_64

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.