From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by sourceware.org (Postfix) with ESMTPS id 9D070386F467 for ; Thu, 18 Feb 2021 13:07:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9D070386F467 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MhDEq-1lpvPD0LHW-00eHuR for ; Thu, 18 Feb 2021 14:07:49 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 7D067A80B83; Thu, 18 Feb 2021 14:07:48 +0100 (CET) Date: Thu, 18 Feb 2021 14:07:48 +0100 From: Corinna Vinschen To: cygwin-developers@cygwin.com Subject: Re: set_open_status Message-ID: Reply-To: cygwin-developers@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com References: <562a95df-6685-c6cf-d57d-dfd292925b23@cornell.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:jEl1WPkL3hnKMTV/6fGDlj++GuJHDXUrxiAHt1dXmXoL+M/BEZ7 vzi8qoIGiRbAiDG1mYAGChs78cVquAX0DbUwc84oYNywbeFMt6wy/a5dszRLQ5HGug0wZTb +HYe7V5jWMmorB4KL0T6htIYjsi1aMkYHqWsrH1ErEcwtOQTHuhVgrIk6bjP8YWQECsRJwu 3eQfj1zCPcz7mttoSqT1A== X-UI-Out-Filterresults: notjunk:1;V03:K0:5CostGWWJeI=:qvxMH4t0rmin5G8/mxFwFw LD5VV5dsxsy38AAUmesbl2P2AmwNRvc0zWDrlvK/nXo48wqwsBOMZfHq5Uz7TZdZqUkZj5HX8 Q/ouYZULDHYLEzbrhr8XEgoSYUX6MYMxwr47LxpVeuvn83Owx8wKWUEy5WoWnOlJO+BCwvF/d IMsums93Es6YN77Dtqd1e28HspWEe6NgYuF5ME6ll1PRDEB8V406uLqJcdPncMEWHyhwN5LR6 mfdUYDaEQu69lvMtYVaU5QiENfLhUgNbmn34cZ0469GybQSZR7UP+VBRQx/X9XhwUsyVW19NT We4bKvV+S1M27Li9/ZvZJPPI+QUEYJkixt0+vxIp24Ri2H2ff8idmLCzhVqZEJZvzGwzd7F2o Y8VFJNbajQQPRNNq5e3sBo/retTz0r1I8wwZOmokFN96CA0IYKmZLPnvVMOj1ORzpVvjR3DHr RJ4QunUkng== X-Spam-Status: No, score=-107.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2021 13:07:52 -0000 On Feb 18 10:07, Corinna Vinschen via Cygwin-developers wrote: > On Feb 17 16:35, Ken Brown via Cygwin-developers wrote: > > Most fhandlers call set_open_status in their 'open' method before a > > successful return. I just noticed that fhandler_fifo::open doesn't do this. > > I thought at first that it was an oversight on my part from when I > > overhauled the FIFO implementation, but I just checked fhandler_fifo.cc as > > of cygwin 2.9.0, and I don't see it there either. > > > > Is there some reason this would be wrong for FIFOs? > > I guess this was just an oversight. It's certainly not fatal, given how > open_status is used exclusively by fhandler_base::reset_to_open_binmode() > in turn *only* called from setmode(fd, 0). This is quite a bordercase. > Combined with FIFOs supporting only O_BINARY mode anyway... > > It won't hurt to add the set_open_mode call to FIFOs but it won't change > anything, except avoiding to report O_TEXT mode after a call to > setmode(fd, 0). > > Maybe it would be better to change fhandler_base::reset_to_open_binmode > instead. Right now, if open_status hasn't been initialized, it prefers > O_TEXT over O_BINARY. That's unfortunate, because it forces us to call > set_open_mode everywhere to make sure the mode is stored correctly for > this single, and seldom, invocation of setmode(fd, 0). It would be nice > if set_open_mode would only be necessary on fhandlers supporting O_TEXT > at all. On second thought, this should do the trick: diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index e457e2785e9b..ac9ee7c9e787 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -274,7 +274,8 @@ class fhandler_base void reset_to_open_binmode () { set_flags ((get_flags () & ~(O_TEXT | O_BINARY)) - | ((open_status.wbinary || open_status.rbinary) + | (((open_status.wbinset ? open_status.wbinary : 1) + || (open_status.rbinset ? open_status.rbinary : 1)) ? O_BINARY : O_TEXT)); } Corinna