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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content