This is impacting all the usbnsh configurations.  I can take another
look later this evening
https://github.com/apache/incubator-nuttx/pull/2526

--Brennan

On Fri, Dec 11, 2020 at 5:05 AM Gregory Nutt <spudan...@gmail.com> wrote:
>
> Several other PRs specifically removed support for fclose (stdin).  Are
> you certain you want to restore it?  I think this needs more analysis
> and resolution with the previous changes that removed the fclose() of
> stdin, stdout, and stderr.
>
> On 12/10/2020 5:37 PM, Masayuki Ishikawa wrote:
> > Suzuki-san,
> >
> > Please send a PR (Pull Request) to
> > https://github.com/apache/incubator-nuttx-apps/
> >
> > On Thu, Dec 10, 2020 at 5:24 PM SUZUKI Keiji <zuki.ebe...@gmail.com> wrote:
> >
> >> Hi,
> >>
> >> I use STM32F407G-DISC1 (MB997D) and build nuttx on macOS Mojave (10.14.6).
> >>
> >> The following error occurs with the default configuration of
> >> stm32f4discovery:usbnsh.
> >>
> >>    NuttShell (NSH) NuttX-10.0.0
> >>    nsh> nsh: nsh_session: readline failed: 9
> >>
> >> The reason seems that instream->fs_fd is -1 instead of 0 in the readline()
> >> function called by
> >> nsh_session().
> >>
> >> This error occurs in version 10.0-RC0 and after (I checked 10.0-RC0, 10.0
> >> and current master)
> >> but does not occur in 9.1 and before (I checked 9.1, 8.2 and 7.31).
> >>
> >> The following patch fixed it in my environment but I don't know this is a
> >> correct fix.
> >>
> >> === from here ===
> >>
> >> diff --git a/nshlib/nsh_usbconsole.c b/nshlib/nsh_usbconsole.c
> >> index 28f63bcc..768a621b 100644
> >> --- a/nshlib/nsh_usbconsole.c
> >> +++ b/nshlib/nsh_usbconsole.c
> >> @@ -77,8 +77,8 @@
> >>
> >> static void nsh_configstdio(int fd, FAR struct console_stdio_s *pstate)
> >> {
> >> - /* Make sure the stdout, and stderr are flushed */
> >> -
> >> + /* Make sure the stdin is closed and the stdout, and stderr are flushed
> >> */
> >> + fclose(stdin);
> >> fflush(stdout);
> >> fflush(stderr);
> >>
> >> @@ -88,6 +88,9 @@ static void nsh_configstdio(int fd, FAR struct
> >> console_stdio_s *pstate)
> >> dup2(fd, 1);
> >> dup2(fd, 2);
> >>
> >> + /* fdopen stdin */
> >> + fdopen(0, "r");
> >> +
> >> /* Setup the stdout */
> >>
> >> pstate->cn_outfd = 1;
> >>
> >> =====
> >>
> >> Thanks,
> >> SUZUKI Keiji
> >>
>

Reply via email to