<p>I'm looking to call a subprocess with a file descriptor opened to a given pipe such that the open() call does not hang waiting for the other side of the pipe to receive a connection.</p>

<p>To demonstrate:</p>

<pre><code>$ mkfifo /tmp/foobar.pipe
$ some_program --command-fd=5 5&lt;/tmp/foobar.pipe
</code></pre>

<p>In this case, <code>some_program</code> is not run until some process has <code>/tmp/foobar.pipe</code> open for write; however, <code>some_program</code> has useful effects even when it isn't receiving commands, so desired behavior is for <code>some_program</code> to be immediately executed.</p>

<p>Mechanisms to do this by exec'ing through an alternate scripting language (python, perl, etc) or a C wrapper which open <code>/tmp/foobar.pipe</code> with the <code>O_NONBLOCK</code> flag are obvious; I'm looking for a pure-bash solution, should one be possible.</p>

The only way I know getting this kind of result is a hack:
```
```
mkfifo /tmp/foobar.in
mkfifo /tmp/foobar.out
( cat </tmp/foobar.in ) >/tmp/foobar.out &
some_program --command-fd=5 5</tmp/foobar.out
```
```
perhaps this helps :-)