This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 4981dbe32 apps/examples/pipe:can't print info to screen after calling 
redirect_test func.
4981dbe32 is described below

commit 4981dbe32b95e283e2daefc9c59a21a72d0c8082
Author: wurui3 <[email protected]>
AuthorDate: Mon Aug 28 21:29:16 2023 +0800

    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 <[email protected]>
---
 examples/pipe/pipe_main.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/examples/pipe/pipe_main.c b/examples/pipe/pipe_main.c
index 3df588a35..25ca6c5f2 100644
--- a/examples/pipe/pipe_main.c
+++ b/examples/pipe/pipe_main.c
@@ -45,7 +45,7 @@ static void *open_write_only(pthread_addr_t 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);
   if (((int *)fd_addr)[1] < 0)
     {
@@ -76,7 +76,7 @@ int main(int argc, FAR char *argv[])
 #if CONFIG_DEV_FIFO_SIZE > 0
   /* Test FIFO logic */
 
-  printf("\npipe_main: Performing FIFO test\n");
+  fprintf(stderr, "\npipe_main: Performing FIFO test\n");
 
   pthread_t writeonly;
   void *status;
@@ -159,7 +159,7 @@ int main(int argc, FAR char *argv[])
 
   /* 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();
   if (ret != 0)
     {
@@ -167,19 +167,19 @@ int main(int argc, FAR char *argv[])
       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
-  printf("\npipe_main: Skipping FIFO test\n");
+  fprintf(stderr, "\npipe_main: Skipping FIFO test\n");
 
 #endif /* CONFIG_DEV_FIFO_SIZE > 0 */
 
 #if CONFIG_DEV_PIPE_SIZE > 0
   /* Test PIPE logic */
 
-  printf("\npipe_main: Performing pipe test\n");
+  fprintf(stderr, "\npipe_main: Performing pipe test\n");
 
   ret = pipe(fd);
   if (ret < 0)
@@ -210,7 +210,7 @@ int main(int argc, FAR char *argv[])
 
   /* Perform the pipe redirection test */
 
-  printf("\npipe_main: Performing redirection test\n");
+  fprintf(stderr, "\npipe_main: Performing redirection test\n");
   ret = redirection_test();
   if (ret != 0)
     {
@@ -218,15 +218,15 @@ int main(int argc, FAR char *argv[])
       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
-  printf("\npipe_main: Skipping pipe test\n");
+  fprintf(stderr, "\npipe_main: Skipping pipe test\n");
 
 #endif /* CONFIG_DEV_PIPE_SIZE > 0 */
 
-  fflush(stdout);
+  fflush(stderr);
   return 0;
 }

Reply via email to