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 Fri, Aug 13, 2010 at 1:25 PM, Eric Blake <eblake@redhat.com> wrote:
> Then again, cat should exist until something causes the input side of
> its pipe to declare EOF; so I guess there's no race in this example
> after all. ?Rather, it looks like a limitation in cygwin1.dll. ?I don't
> know why bash is unable to duplicate the output end of the pipe to the
> echo process, unless cygwin's /dev/fd handling doesn't work on pipes.
> But that's highly likely that you are dealing with yet another one of
> cygwin's pipe handling shortfalls.

Would these shortfalls also explain why this script doesn't do what
I'd expect (that is, output "hello" and exit)? It just hangs right now
--- this is the ps output:

I    8580    7740    7740       6340    3 4412345 13:41:41 /usr/bin/cygpath
I    7724    7740    7740       4796    3 4412345 13:41:41 /usr/bin/cygpath
O    1736    7740    7740       8796    3 4412345 13:41:41 /usr/bin/echo

So, err, echo is waiting to output, and cygpath is waiting to receive
input? I don't see why the script shouldn't be making forward
progress.

#!/bin/bash

tmpdir=$(mktemp -dt cygfilter-XXXXXX)
stdout_pid=
stderr_pid=

function cleanup() {
    [[ -n $stdout_pid ]] && /bin/kill $stdout_pid
    [[ -n $stderr_pid ]] && /bin/kill $stderr_pid
    rm -rf "$tmpdir"
}

trap cleanup 0

mkfifo "$tmpdir/f-out"
mkfifo "$tmpdir/f-err"

cygpath -u -f "$tmpdir/f-out"&
stdout_pid=$!
disown %%

cygpath -u -f "$tmpdir/f-err" >&2 &
stderr_pid=$!
disown %%

"$@" >"$tmpdir/f-out" 2>"$tmpdir/f-err"


# Run as cygfilter /bin/echo hello
# -----------

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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