DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 51JBgn0Q3920421
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 51JBgn0Q3920421
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=MRt3gbpB
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80E943858415
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1739965367;
	bh=VMX0yWqPf9ToeBfEq5UQlq+5osDrH7WCqwwC1FW4YoA=;
	h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=MRt3gbpB9V8NBc3POxUoJcNdNdHKki/PzYPqg7y0qvLlbtP0iClEvF4yiS7LaZPK0
	 thO1VXEW34OnMtfzZYbrFi69Ey2C6Yjii4O1A15MmT1ToLq6uOWhb13t4hRFFWt+MV
	 85IW0vFyf1hjVyQ2NY+q6kB+HRSY6eiIZalOgd4c=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BEEF3858C42
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7BEEF3858C42
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739965329; cv=none;
 b=p1Mgt0mGQZr00LQKSOuw8uqfOClW8sEJCLnwDUlsK9Ootaq8GXapo6GVZ+KPgvZpa4fGdmEuohAH+fuklYjBga6WIIJmkn45L2D7U8BR05KFNuFAMWRG52EGRqF8TUlDp0IO5psWILkIASIyG/eQF157m2j1nz7z8yzKYYOYUqI=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1739965329; c=relaxed/simple;
 bh=NiSfnL/gYUiRYvM6Qp7eYaGAd4sHPJbzwrlsPKTKlJw=;
 h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature;
 b=G+gW3wL0Ry3VQ5zvN+it8yucC0eevPAxef3fTMirmM/xkKl0kvPj2RY3CQoZ00QwofEO4fEVZ87zcNujRQonBmR3iNp+R+jDVxx775v0Bi10+J3zSpnwK+L66+cKfeQaf8rxmjvuzm+Egxsp4PbNNWAdPma22uFVbPBBnA9yMSQ=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BEEF3858C42
Date: Wed, 19 Feb 2025 20:42:05 +0900
To: cygwin@cygwin.com
Subject: Re: lost output after pipe redirection
Message-Id: <20250219204205.ba1dfa7265ba68cf0deee14e@nifty.ne.jp>
In-Reply-To: <20250219073813.7b26b8db73e055b9f1d2c75b@nifty.ne.jp>
References: <6bc117eb-ece2-43a7-91ae-6ab17d62f6ca@gmail.com>
 <20250218205647.41b64c0fded65dc9bc681589@nifty.ne.jp>
 <32abf18d-488e-4658-b006-96c62cfd1f00@gmail.com>
 <20250219073813.7b26b8db73e055b9f1d2c75b@nifty.ne.jp>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
Content-Type: multipart/mixed;
 boundary="Multipart=_Wed__19_Feb_2025_20_42_05_+0900_kQr_TfRt45TbBqtX"
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Takashi Yano via Cygwin <cygwin@cygwin.com>
Reply-To: Takashi Yano <takashi.yano@nifty.ne.jp>
Errors-To: cygwin-bounces~archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>

This is a multi-part message in MIME format.

--Multipart=_Wed__19_Feb_2025_20_42_05_+0900_kQr_TfRt45TbBqtX
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

On Wed, 19 Feb 2025 07:38:13 +0900
Takashi Yano wrote:
> On Tue, 18 Feb 2025 21:59:36 +0100
> Marco Atzeriwrote:
> > On 18/02/2025 12:56, Takashi Yano via Cygwin wrote:
> > > Hi Marco,
> > > 
> > > On Mon, 17 Feb 2025 09:28:11 +0100
> > > Marco Atzeri wrote:
> > >> Hi Takashi,
> > >>
> > >> I think there is still issue on pipe redirection output lost.
> > >> I have two cases where during package tests the test are reported as
> > >> failures as the output is missing, while running the test stand alone
> > >> the output is produced as expected.
> > >>
> > 
> > >> --------------------------------------------------------------
> > > 
> > > This is not a pipe problem, but just a path problem for gdbmtool.
> > > Please try the patch attached.
> > 
> > Thanks Takashi,
> > 
> > it works.
> > I reported the solution upstream.
> 
> I forgot to mention, but this problem does not occur in Linux.
> I don't know why.

I digged this deeper.

I noticed that this is not a simple path problem. Even if gdbmtool.exe
is in the path, running it fails if the directory named gdbmtool exists
in the path prior to gdmtool.exe.

Simple test case which reproduce this problem is attached. This problem
occurs if the executable is linked with libtool.

The expected output of the test case is:
Hello 1
Hello 2
Hello 3

However, the output in cygwin is:
Hello 1
127
Hello 3

The culprit would be libtool or cygwin1.dll. libtool is the large
scale shell script, so I do not find the cause so far.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

--Multipart=_Wed__19_Feb_2025_20_42_05_+0900_kQr_TfRt45TbBqtX
Content-Type: text/plain;
 name="reproducer.sh"
Content-Disposition: attachment;
 filename="reproducer.sh"
Content-Transfer-Encoding: 7bit

#!/bin/sh
rm -rf a/hello b
mkdir -p b
cd b
cat > hello.c <<EOF
#include <stdio.h>
int main(int argc, char *argv[])
{
	printf("Hello %s\n", argc > 1 ? argv[1] : "");
	return 0;
}
EOF
gcc -c hello.c -o hello.o && libtool --mode=link gcc hello.o -o hello
cd ..
export PATH="${PWD}/a:${PWD}/b:/usr/bin"
hello 1 || echo $?
mkdir -p a/hello
hello 2 || echo $?
cd b
gcc hello.c -o hello
cd ..
hello 3 || echo $?

--Multipart=_Wed__19_Feb_2025_20_42_05_+0900_kQr_TfRt45TbBqtX
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


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

--Multipart=_Wed__19_Feb_2025_20_42_05_+0900_kQr_TfRt45TbBqtX--
