apps/examples/pipe:can't print info to screen after calling redirect_test func.
reason:stdin/stdout was redirected and closed in redirect_test.c. measures:change all printf() to fprint(stderr,...) in pipe_main.c, and modify fflush(stdout) to fflush(stderr) in line 231. Signed-off-by: wurui3 <wurui3@xiaomi.com>
This commit is contained in:
parent
8d7497f7fb
commit
4981dbe32b
@ -45,7 +45,7 @@ static void *open_write_only(pthread_addr_t pvarg)
|
|||||||
{
|
{
|
||||||
void *fd_addr = (void *)pvarg;
|
void *fd_addr = (void *)pvarg;
|
||||||
|
|
||||||
printf("open_write_only: Opening FIFO for write access\n");
|
fprintf(stderr, "open_write_only: Opening FIFO for write access\n");
|
||||||
((int *)fd_addr)[1] = open(FIFO_PATH1, O_WRONLY);
|
((int *)fd_addr)[1] = open(FIFO_PATH1, O_WRONLY);
|
||||||
if (((int *)fd_addr)[1] < 0)
|
if (((int *)fd_addr)[1] < 0)
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
#if CONFIG_DEV_FIFO_SIZE > 0
|
#if CONFIG_DEV_FIFO_SIZE > 0
|
||||||
/* Test FIFO logic */
|
/* Test FIFO logic */
|
||||||
|
|
||||||
printf("\npipe_main: Performing FIFO test\n");
|
fprintf(stderr, "\npipe_main: Performing FIFO test\n");
|
||||||
|
|
||||||
pthread_t writeonly;
|
pthread_t writeonly;
|
||||||
void *status;
|
void *status;
|
||||||
@ -159,7 +159,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
|
|
||||||
/* Perform the FIFO interlock test */
|
/* Perform the FIFO interlock test */
|
||||||
|
|
||||||
printf("\npipe_main: Performing pipe interlock test\n");
|
fprintf(stderr, "\npipe_main: Performing pipe interlock test\n");
|
||||||
ret = interlock_test();
|
ret = interlock_test();
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
@ -167,19 +167,19 @@ int main(int argc, FAR char *argv[])
|
|||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("pipe_main: FIFO interlock test PASSED\n");
|
fprintf(stderr, "pipe_main: FIFO interlock test PASSED\n");
|
||||||
|
|
||||||
printf("pipe_main: FIFO test PASSED\n");
|
fprintf(stderr, "pipe_main: FIFO test PASSED\n");
|
||||||
|
|
||||||
#else
|
#else
|
||||||
printf("\npipe_main: Skipping FIFO test\n");
|
fprintf(stderr, "\npipe_main: Skipping FIFO test\n");
|
||||||
|
|
||||||
#endif /* CONFIG_DEV_FIFO_SIZE > 0 */
|
#endif /* CONFIG_DEV_FIFO_SIZE > 0 */
|
||||||
|
|
||||||
#if CONFIG_DEV_PIPE_SIZE > 0
|
#if CONFIG_DEV_PIPE_SIZE > 0
|
||||||
/* Test PIPE logic */
|
/* Test PIPE logic */
|
||||||
|
|
||||||
printf("\npipe_main: Performing pipe test\n");
|
fprintf(stderr, "\npipe_main: Performing pipe test\n");
|
||||||
|
|
||||||
ret = pipe(fd);
|
ret = pipe(fd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -210,7 +210,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
|
|
||||||
/* Perform the pipe redirection test */
|
/* Perform the pipe redirection test */
|
||||||
|
|
||||||
printf("\npipe_main: Performing redirection test\n");
|
fprintf(stderr, "\npipe_main: Performing redirection test\n");
|
||||||
ret = redirection_test();
|
ret = redirection_test();
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
@ -218,15 +218,15 @@ int main(int argc, FAR char *argv[])
|
|||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("pipe_main: PIPE redirection test PASSED\n");
|
fprintf(stderr, "pipe_main: PIPE redirection test PASSED\n");
|
||||||
|
|
||||||
printf("pipe_main: PIPE test PASSED\n");
|
fprintf(stderr, "pipe_main: PIPE test PASSED\n");
|
||||||
|
|
||||||
#else
|
#else
|
||||||
printf("\npipe_main: Skipping pipe test\n");
|
fprintf(stderr, "\npipe_main: Skipping pipe test\n");
|
||||||
|
|
||||||
#endif /* CONFIG_DEV_PIPE_SIZE > 0 */
|
#endif /* CONFIG_DEV_PIPE_SIZE > 0 */
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stderr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user