From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by sourceware.org (Postfix) with ESMTPS id BC84F3858C51 for ; Tue, 17 May 2022 07:38:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC84F3858C51 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MZkYx-1oLtU322hL-00Wn0b for ; Tue, 17 May 2022 09:38:52 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 5EE46A8071E; Tue, 17 May 2022 09:38:51 +0200 (CEST) Date: Tue, 17 May 2022 09:38:51 +0200 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: ps | cat broken in newlib-cygwin git head (master) Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <20220517043712.c3208bf70ad0d338a562aaf6@nifty.ne.jp> <20220517121724.d801487688110f34f2e5d764@nifty.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220517121724.d801487688110f34f2e5d764@nifty.ne.jp> X-Provags-ID: V03:K1:JnMpsqqEU/KjDxw+0hRV+PZKYE6UoUAFlpgv4Bveg+T8u4643l8 i0TsTlyfXtoMav+NoQOBzJqE68ROkhTx77jLRrqvJ/pdpyg0bp3xJcxGZEZhERWwzkbadxe VXW0oKLyc+Ws/KDD+O94T3bKwXx4Il31A2Vk92obNbwvpHSgNZmEoFeX3A2BcSKefmLcnVr E97O4Sfetfseveo7IS6Yw== X-UI-Out-Filterresults: notjunk:1;V03:K0:yFlqJIsJfco=:oIbFl4wyFw8dhGZC6WcACw gnfcxYrbNpuFccSZvwG8IVDjkcXwdh4B5YLYaaaIW1mUWkpF4d3posbPClVwQqEvgO+KDLfXU hecbEQ02+U9tJ9bnhrDlOE6MYdxz7jg4GaXNVcZiJ12yisQ95G5+DlD9laKSU3aVE08WDtwLy 3SlMjXPqREvFmwBQ1FKFjRV5WC0mzeQ6jzEavMP/XQilk2USE5Rt8nHZ0srq2dcbWwrRY4aKY u2KCZPguknMnGylRk2cQJ+gI+4eFkYNVZuwOT6COtKYIbPujqC/l3lFfurFRrxXG+7hvIYN8n uLGopaJgP6fyP0NXUtf+g3HwJOADnzCszaRp1cVpXuVn5dQh9kUlaXNn9dyEaY7jBcV454j7y pybrgv2I5q3+NVdxpOpqi2A2xlvlapB360bC+c0pJH1x+tbJYXeZ3IB+49Uyo8GDNO5jlLJhi iIABz2m5DSNxlZ3TLBGb49UST3+tGLa5cO435q+Dxr84zkB8lQjKxCxiSWevsgb5QsIdCBWd8 y0itB3iTJ4JGT/hANhefOwhNRYUtU4xmmp0nbLbUsL9TLTimjycbyHEp3QFhTnYnfteFMbGv0 8zAWL5VMKNKJrlB/ghWOsQOvhSOqqPhv1aR6XsaY6AikJZZ22fdmQ6nHfprtTptgnPMfcUcEy sorTYxzoQ9BTbnTRYMqShUgyMCubxCCtvNNc1O+e4au8cYj3HSfwibJhCP9+i07xfZx2w2i6s RQsxRXbU6Bwp02rj X-Spam-Status: No, score=-101.3 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_FAIL, SPF_HELO_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2022 07:39:00 -0000 Hi Takashi, please send this to the newlib ML, ideally as a reply to the patch or patchset, CCing Matt and Sebastian. Thanks, Corinna On May 17 12:17, Takashi Yano wrote: > On Tue, 17 May 2022 04:37:12 +0900 > Takashi Yano wrote: > > I found that "ps | cat" outputs nothing with the current git head (master) > > of newlib-cygwin. However, just "ps" and "ls | cat" works. > > > > This happens after the commit: > > > > commit 26747c47bc0a1137e02e0377306d721cc3478855 > > Author: Matt Joyce > > Date: Tue May 3 06:51:22 2022 +0200 > > > > Add stdio_exit_handler() > > > > Add a dedicated stdio exit handler to avoid using _GLOBAL_REENT in exit(). > > > > > > Is this the problem of cygwin side? Or newlib? > > > > I also found "stdbuf -o 0 ps | cat" works. It seems that this problem is > > caused by buffering of stdout. > > I am not sure this is the right thing, however, I found the following > patch solves the issue. It seems that initializing __stdio_exit_handler > is missing. > > diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c > index 19952d4e0..e759b5402 100644 > --- a/newlib/libc/stdio/findfp.c > +++ b/newlib/libc/stdio/findfp.c > @@ -63,6 +63,8 @@ struct _glue __sglue = {NULL, 3, &_GLOBAL_REENT->__sf[0]}; > #endif > #endif > > +static void stdio_exit_handler (void); > + > #if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) > _NOINLINE_STATIC void > #else > @@ -109,6 +111,11 @@ std (FILE *ptr, > if (__stextmode (ptr->_file)) > ptr->_flags |= __SCLE; > #endif > + > + if (__stdio_exit_handler == NULL) { > + __sinit (_GLOBAL_REENT); > + __stdio_exit_handler = stdio_exit_handler; > + } > } > > static inline void > > -- > Takashi Yano > > -- > 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