Why I got 141 from PIPESTATUS using certain command line pipe ?

Solution Unverified - Updated -

Issue

  • Why I got 141 from PIPESTATUS using certain command line pipe ?

The user tried to get status code of certain command using PIPESTATUS array , and got strange return code.

aaa=`{ find . | head -1 ; echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} ;  }`
echo $aaa

They expected that both of ${PIPESTATUS[0]} and ${PIPESTATUS[1]} will return 0.
But they found that sometimes, ${PIPESTATUS[0]} return strange return code 141.

]$ aaa=`{ find . | head -1 ; echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} ;  }`
]$ echo $aaa
. 141 0

Why 'find .' returns code 141 ?

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

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.