This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Broken process substitution


On 08/13/2010 02:04 PM, Daniel Colascione wrote:
> Try "echo hello > >(cat)" -- that's supposed to output "hello".

What makes you think it's supposed to echo hello?  That's system
specific on what will happen.  According to the bash manual,

>(cat)

is evaluated first, and will result in a /dev/fd reference, or a named
pipe (it so happens that it is a /dev/fd reference in cygwin).  But this
pipe is tied to the subprocess, so it only exists as long as the
subprocess exists.

Then bash does the redirection.  If >(cat) has already gone away, then
the resulting string /dev/fd/63 no longer exists.  So redirecting to a
non-existent file fails.  But if cat hasn't finished executing yet, then
the redirection will succeed.

Classic data race.  Your expectations are wrong, and this is not a bug
in cygwin, per se.

On the other hand, a named fifo might be more persistent; bash might
keep the fifo around until the entire statement is complete, rather than
keeping the pipe and /dev/fd reference for the life of the subprocess.
But I'd have to recompile bash to force it to use a named fifo, and we
already know that named fifos have bugs in cygwin.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]