delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/08/13/16:56:44

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,TW_MK,TW_YG,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <AANLkTin_DeqXOnK=v97XTLjAem-4CWypssJC+MVK5+Dp@mail.gmail.com>
References: <00c301cb3b22$ae416800$0ac43800$@gmail.com> <4C65A83F DOT 4010608 AT redhat DOT com> <4C65AA3A DOT 70303 AT redhat DOT com> <AANLkTin_DeqXOnK=v97XTLjAem-4CWypssJC+MVK5+Dp AT mail DOT gmail DOT com>
Date: Fri, 13 Aug 2010 13:56:30 -0700
Message-ID: <AANLkTikD-tkT91NzXu+-ws-dHz6SdHepj_0oT=qm3g8T@mail.gmail.com>
Subject: Re: Broken process substitution
From: Daniel Colascione <dan DOT colascione AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Fri, Aug 13, 2010 at 1:44 PM, Daniel Colascione
<dan DOT colascione AT gmail DOT com> wrote:
> On Fri, Aug 13, 2010 at 1:25 PM, Eric Blake <eblake AT redhat DOT 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. =A0Rather, it looks like a limitation in cygwin1.dll. =A0I do=
n'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:

Actually, the seemingly-equivalent version below works fine. Maybe
there was a race between the cygpath's starting to read the fifo and
the last line starting to write to it.

The *real* bug seems to be triggered by the following commands:

#!/bin/sh
cd /tmp
mkfifo blah
( echo hello > blah )&
cat blah

On other systems (OS X and Linux), that just outputs "hello", then
both processes exit. On Cygwin, the writer is blocked indefinitely and
has to be SIGKILLed --- even if a reader then starts. And the reader
acts as if there were no writer at all.

--------

#!/bin/bash
set -e

tmpdir=3D$(mktemp -dt cygfilter-XXXXXX)

function cleanup() {
    rm -rf "$tmpdir"
}

trap cleanup 0

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

cygpath -u -f- < "$tmpdir/f-out"&
cygpath -u -f- < "$tmpdir/f-err" >&2 &

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

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019