X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:references :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=nHbVScxUhkWb4KU5HbC10ooVBP92Kw3hWO9s7YiWq+slzfWsZfDx/ 3FeHSz0DwmGmscBqfMarfB5UtsmMW1kK71K6/CeH8HgoidsYS63p0nBejZOdfdl6 Yod4gx5OIyEuV7bY5xmwdAP/p96Ut8rE0/8q/FcVzZKE5iOhXykw20= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:references :content-type:content-transfer-encoding:mime-version; s=default; bh=iu6k0ThmiDRqAUJOqIhENIMFvW4=; b=EWyWHMDitKdP4LqFG6D/XQYkO8Uj WOctQ/uTF9vVspegy6Vtl0FiAqVaqtX5rWHZ6PafON6kpiOvWNIapb9gc5EZ01XI G8xJC6GPX03i8nJIfam5y3IWRUpIieeqVc7x7iUcqfUtnBFHT6CjxKQ0jcusfGEH 2VZgPkvOuB/ehic= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=extensive, awesome X-HELO: smtprelay.synopsys.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1549726409; bh=SXpyaIqsGE3zQIqv34PW7WVPnnCSMIaiUkYIJBGaUPQ=; h=From:To:Subject:Date:References:From; b=eaCVD3u801Ln4KfaOZl9zTBnArDlhSr8haZcFjrtHcTnlR1041oleOQMgUGM8m2ea WQmJa9+wNu17AE77JGafArB8Q923HFRutzPor3C539mqP1NWgp6DXx/SFCbCNoC59E pkcdue356i86cGcfHU6WBuUJMeBRokmiQygnDsP9zT5kwa5tCAtKms25RF2oVnxI/r AI3KAmOXbzsDyTOLMi4WXkyYMcMxdv4wI2SFQbyGpEkfbFBCq4rzx36cVktcWymQkS MnFYaGzWGDSSIHMtjbcaYXh7PcPn4J1fEkgADnTOeyIWbJudku2nXHpNInRHB5VB8f g7jMJ54ewtqMQ== From: Tom Honermann To: Tom Honermann , "cygwin AT cygwin DOT com" , Cameron Gunnin , "Marc-Andre Laverdiere" Subject: Re: fcntl with O_APPEND fails to force append mode on stderr for native Windows programs Date: Sat, 9 Feb 2019 15:33:28 +0000 Message-ID: <9E5DE55D2546134DACFE4D3C117B36FDAD0CF450@us01wembx1.internal.synopsys.com> References: <9E5DE55D2546134DACFE4D3C117B36FDAD0CEE1D AT us01wembx1 DOT internal DOT synopsys DOT com> <20190209145122 DOT GY13951 AT calimero DOT vinschen DOT de> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id x19FcW4S017404 On 2/9/2019 9:51 AM, Corinna Vinschen wrote: > On Feb 8 22:25, Tom Honermann wrote: >> The following program demonstrates the problem. >> [...] >> Here is where things go bananas. If the program is run with stdout >> initially redirected to a pipe, then the stderr output from the native >> Windows program ends up overwriting the stdout output from the two >> calls to echo: >> >> $ ./test | cat >> $ cat out >> The syntax of this command is: >> >> NET >> [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP | >> HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START | >> STATISTICS | STOP | TIME | USE | USER | VIEW ] >> >> Note that the lines containing "first" and "second" are now absent in >> the file. > Thanks for the testcase. I tracked this down to a bug when calling > native (non-Cygwin) apps. If the descriptor is in O_APPEND mode, we > have to set the file offset to EOF before calling native apps. However, > this only worked reliably for the first descriptor in O_APPEND mode, but > only by chance for subsequent descriptors in O_APPEND mode. Your > example code with the extra pipe to `cat' triggered the misbehaviour. > > I fixed that in git master: > https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=0be0b8f0335e > > This will be in the 3.0.0 release. > > I just uploaded new developer snapshots to https://cygwin.com/snapshots/ > You only need to replace the Cygwin DLL for testing. Please give it a try. Thank you, Corinna! This does appear to fix the problem. I verified the snapshot with the original test case and the one above and both work as expected now. We'll do some more extensive testing and report back if we find any further issues. You are awesome! Tom. -- 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