Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 6
    this exec 3>P cause hang in bash, why? Commented Dec 4, 2017 at 16:25
  • @Wang It shouldn't. If it does then you're probably not doing the same thing as the as the POC code in the question. The only reason I can think that it would block is if you're instead doing something like exec 2>P, and you have trace mode turned on (set -x), in which bash is going to write to the pipe, but there's no reader so it blocks waiting for something to read. Commented Feb 19, 2018 at 13:45
  • 9
    @Wang @Patrick Indeed exec 3>P hangs in bash on my machine too. This is because there is no process reading from P. Thus, the solution was to swap lines exec 3>P and program < P & (adding the ampersand so that program runs in background). Commented Oct 17, 2018 at 9:04
  • 3
    @macieksk How about exec 3<>P? It counts as a writer and as a reader. Useful in case one wants program in the foreground. Commented Feb 14, 2021 at 3:39
  • fails when the reader is python interpreter: it does not execute the input commands! Commented Dec 31, 2022 at 10:02