You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2021/11/22 18:37:18 UTC

[incubator-nuttx] branch master updated: libc/psignal: Output the message to STDERR_FILENO instead STDOUT_FILENO

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

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


The following commit(s) were added to refs/heads/master by this push:
     new e5cf5fa  libc/psignal: Output the message to STDERR_FILENO instead STDOUT_FILENO
e5cf5fa is described below

commit e5cf5faa8625615e37bf8fd09e5efbc11ef14783
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Nov 18 02:53:29 2021 +0800

    libc/psignal: Output the message to STDERR_FILENO instead STDOUT_FILENO
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 libs/libc/signal/sig_psignal.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libs/libc/signal/sig_psignal.c b/libs/libc/signal/sig_psignal.c
index 80b5f29..6bada1a 100644
--- a/libs/libc/signal/sig_psignal.c
+++ b/libs/libc/signal/sig_psignal.c
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <unistd.h>
 
 /* Uses streams... not available to kernel code */
 
@@ -72,15 +73,15 @@ void psignal(int signum, FAR const char *message)
       fprintf(stderr, "%s\n", strsignal(signum));
     }
 #else
-  /* No stderr!  Write to whatever alternative console is available */
+  /* No stream! Write to file handle(fd == 2) directly without buffer */
 
   if (message != NULL)
     {
-      printf("%s: %s\n", message, strsignal(signum));
+      dprintf(STDERR_FILENO, "%s: %s\n", message, strsignal(signum));
     }
   else
     {
-      printf("%s\n", strsignal(signum));
+      dprintf(STDERR_FILENO, "%s\n", strsignal(signum));
     }
 #endif
 }