* ps | cat broken in newlib-cygwin git head (master)
@ 2022-05-16 19:37 Takashi Yano
2022-05-17 3:17 ` Takashi Yano
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Yano @ 2022-05-16 19:37 UTC (permalink / raw)
To: cygwin
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 <matthew.joyce@embedded-brains.de>
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.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ps | cat broken in newlib-cygwin git head (master)
2022-05-16 19:37 ps | cat broken in newlib-cygwin git head (master) Takashi Yano
@ 2022-05-17 3:17 ` Takashi Yano
2022-05-17 7:38 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Yano @ 2022-05-17 3:17 UTC (permalink / raw)
To: cygwin
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 <matthew.joyce@embedded-brains.de>
> 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 <takashi.yano@nifty.ne.jp>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ps | cat broken in newlib-cygwin git head (master)
2022-05-17 3:17 ` Takashi Yano
@ 2022-05-17 7:38 ` Corinna Vinschen
0 siblings, 0 replies; 3+ messages in thread
From: Corinna Vinschen @ 2022-05-17 7:38 UTC (permalink / raw)
To: cygwin
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 <matthew.joyce@embedded-brains.de>
> > 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 <takashi.yano@nifty.ne.jp>
>
> --
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-17 7:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 19:37 ps | cat broken in newlib-cygwin git head (master) Takashi Yano
2022-05-17 3:17 ` Takashi Yano
2022-05-17 7:38 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).