From c826edc0c427e78da554f83c5f4a217b4e94548a Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Fri, 28 Jun 2019 15:22:24 +0800 Subject: [PATCH] [posix-app] enhance RCP failure info (#3950) By default, posix-app disables platform region logs. Even when platform logs are enabled, logs are sent to syslog without printing to stderr. This commit prints error information to stderr on exit, providing the user more direct information about failures. This commit also eliminates the "wait no child process" error message. --- src/posix/platform/hdlc_interface.cpp | 4 ++-- src/posix/platform/misc.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index ac06f7f58..a0b309c73 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -171,8 +171,8 @@ void HdlcInterface::Deinit(void) { VerifyOrExit(mSockFd != -1); - VerifyOrExit(0 == close(mSockFd), perror("close NCP")); - VerifyOrExit(-1 != wait(NULL), perror("wait NCP")); + VerifyOrExit(0 == close(mSockFd), perror("close RCP")); + VerifyOrExit(-1 != wait(NULL) || errno == ECHILD, perror("wait RCP")); mSockFd = -1; diff --git a/src/posix/platform/misc.c b/src/posix/platform/misc.c index 35fb026a0..4ac6ded0e 100644 --- a/src/posix/platform/misc.c +++ b/src/posix/platform/misc.c @@ -112,6 +112,8 @@ void SuccessOrDie(otError aError) } otLogCritPlat("Error: %s", otThreadErrorToString(aError)); + // For better user experience. + fprintf(stderr, "Error: %s\r\n", otThreadErrorToString(aError)); exit(exitCode); }