Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:10:28+00:00 2026-06-10T11:10:28+00:00

In the following test script I run an elementary coprocess to which the echo

  • 0

In the following test script I run an elementary coprocess to which the echo built-in, run in background, attaches its standard-output:

#!/bin/bash
# TEST 1
coproc /bin/sleep 100
echo >&${COPROC[1]} &

The script always fails, for no apparent reason, giving the output:

./test.sh: line 4: ${COPROC[1]}: Bad file descriptor

I wonder if the correct syntax should be rather this one (ampersand moved before redirection):

#!/bin/bash
# TEST 2
coproc /bin/sleep 100
echo & >&${COPROC[1]}

This second example seems to work since it reports no errors during execution, but with this syntax, the redirection is not performed in practice; in fact, consider this other test:

#!/bin/bash
# TEST 3
/bin/echo abc & >xfile

Test 3 creates the file xfile, but does not write anything into it. Curiously, trying again to position the ampersand after the redirection make the echo work fine:

#!/bin/bash
# TEST 4
/bin/echo abc >xfile &

Test 4 creates the file xfile with inside the string abc.

Have some idea on what is causing the coproc redirection error or what the correct syntax is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:10:29+00:00Added an answer on June 10, 2026 at 11:10 am

    You’ve got the answer elsewhere http://lists.gnu.org/archive/html/bug-bash/2012-06/msg00027.html:

    Coproc file descriptors are not available to subshells. They’re
    implemented using pipes, and leaving pipe file descriptors open in
    subshells causes processes to hang and not terminate properly, which
    results in very hard-to-track-down-and-reproduce bugs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following AutoIt script: Run(Notepad.exe, @WindowsDir, @SW_MAXIMIZE) Sleep(1000) Send(Just a test) $anPos
Trying to run the following test.command script on Mac with a double-click. (requirement: MUST
I developed the following CGI script and run on Apache 2 ( http://localhost/test.chtml ).
I have the following simple python test script that uses Suds to call a
I have the following bash script: #DIR is something like: /home/foo/foobar/test/ without any whitespace
Observe the following Python script, Script.py: import subprocess src_directory = 'Z:\z_7z\Some_Directory' zip_file_name = 'Test.7z'
I have the following in a html.erb file: <%= @location_list = [['test',2]] %> <script
I have the following simple script to test the mkdir() function in PHP: <?php
I'm trying to run a test script using crontab within Plesk. The php file
I have the following script #!/bin/sh if [cat stream_should_be_running.txt == 'true']; then #file will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.