From e5cf5faa8625615e37bf8fd09e5efbc11ef14783 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 18 Nov 2021 02:53:29 +0800 Subject: [PATCH] libc/psignal: Output the message to STDERR_FILENO instead STDOUT_FILENO Signed-off-by: Xiang Xiao --- 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 80b5f29c5d..6bada1a38f 100644 --- a/libs/libc/signal/sig_psignal.c +++ b/libs/libc/signal/sig_psignal.c @@ -27,6 +27,7 @@ #include #include #include +#include /* 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 }