nshlib: Fix nsh_usbconsole.c
Summary: - stdin/stdout/stderr are now preallocated in libc and fs_fd in file_struct are also initialized to -1 - So we need to call fdopen() for stdin again as we did before. - Also, cn_outstream and cn_errstream are not needed to be set. - See apps/nshlib/nsh_console.h as well Impact: - nsh_usbconsole.c only Testing: - Tested with stm32f4discovery:usbnsh Signed-off-by: SUZUKI Keiji <zuki.ebetsu@gmail.com> Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
parent
2a11d60246
commit
0c3ee06fb3
@ -75,7 +75,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void nsh_configstdio(int fd, FAR struct console_stdio_s *pstate)
|
static void nsh_configstdio(int fd)
|
||||||
{
|
{
|
||||||
/* Make sure the stdout, and stderr are flushed */
|
/* Make sure the stdout, and stderr are flushed */
|
||||||
|
|
||||||
@ -88,15 +88,16 @@ static void nsh_configstdio(int fd, FAR struct console_stdio_s *pstate)
|
|||||||
dup2(fd, 1);
|
dup2(fd, 1);
|
||||||
dup2(fd, 2);
|
dup2(fd, 2);
|
||||||
|
|
||||||
/* Setup the stdout */
|
/* fdopen to get the stdin, stdout and stderr streams.
|
||||||
|
*
|
||||||
|
* fd = 0 is stdin (read-only)
|
||||||
|
* fd = 1 is stdout (write-only, append)
|
||||||
|
* fd = 2 is stderr (write-only, append)
|
||||||
|
*/
|
||||||
|
|
||||||
pstate->cn_outfd = 1;
|
fdopen(0, "r");
|
||||||
pstate->cn_outstream = fdopen(1, "a");
|
fdopen(1, "a");
|
||||||
|
fdopen(2, "a");
|
||||||
/* Setup the stderr */
|
|
||||||
|
|
||||||
pstate->cn_errfd = 2;
|
|
||||||
pstate->cn_errstream = fdopen(2, "a");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -107,7 +108,7 @@ static void nsh_configstdio(int fd, FAR struct console_stdio_s *pstate)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int nsh_nullstdio(FAR struct console_stdio_s *pstate)
|
static int nsh_nullstdio(void)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ static int nsh_nullstdio(FAR struct console_stdio_s *pstate)
|
|||||||
{
|
{
|
||||||
/* Configure standard I/O to use /dev/null */
|
/* Configure standard I/O to use /dev/null */
|
||||||
|
|
||||||
nsh_configstdio(fd, pstate);
|
nsh_configstdio(fd);
|
||||||
|
|
||||||
/* We can close the original file descriptor now (unless it was one of
|
/* We can close the original file descriptor now (unless it was one of
|
||||||
* 0-2)
|
* 0-2)
|
||||||
@ -224,7 +225,7 @@ restart:
|
|||||||
|
|
||||||
/* Configure standard I/O */
|
/* Configure standard I/O */
|
||||||
|
|
||||||
nsh_configstdio(fd, pstate);
|
nsh_configstdio(fd);
|
||||||
|
|
||||||
/* We can close the original file descriptor (unless it was one of 0-2) */
|
/* We can close the original file descriptor (unless it was one of 0-2) */
|
||||||
|
|
||||||
@ -306,7 +307,7 @@ int nsh_consolemain(int argc, FAR char *argv[])
|
|||||||
/* Configure to use /dev/null if we do not have a valid console. */
|
/* Configure to use /dev/null if we do not have a valid console. */
|
||||||
|
|
||||||
#ifndef CONFIG_DEV_CONSOLE
|
#ifndef CONFIG_DEV_CONSOLE
|
||||||
nsh_nullstdio(pstate);
|
nsh_nullstdio();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Execute the one-time start-up script (output may go to /dev/null) */
|
/* Execute the one-time start-up script (output may go to /dev/null) */
|
||||||
@ -347,7 +348,7 @@ int nsh_consolemain(int argc, FAR char *argv[])
|
|||||||
* valid console device.
|
* valid console device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nsh_nullstdio(pstate);
|
nsh_nullstdio();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user