From 900a059d6825b0132e95377e97af3f500750053e Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Sat, 31 Oct 2020 00:06:00 +0800 Subject: [PATCH] Fix for external log segfault after SIGINT (#844) Signed-off-by: Chen Lihui --- rcl/src/rcl/logging.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rcl/src/rcl/logging.c b/rcl/src/rcl/logging.c index 0a3f343849..7fa76442bd 100644 --- a/rcl/src/rcl/logging.c +++ b/rcl/src/rcl/logging.c @@ -126,6 +126,12 @@ rcl_ret_t rcl_logging_fini() { rcl_ret_t status = RCL_RET_OK; rcutils_logging_set_output_handler(rcutils_logging_console_output_handler); + // In order to output log message to `rcutils_logging_console_output_handler` + // and `rcl_logging_ext_lib_output_handler` is not called after `rcl_logging_fini`, + // in addition to calling `rcutils_logging_set_output_handler`, + // the `g_rcl_logging_num_out_handlers` and `g_rcl_logging_out_handlers` must be updated. + g_rcl_logging_num_out_handlers = 1; + g_rcl_logging_out_handlers[0] = rcutils_logging_console_output_handler; if (g_rcl_logging_rosout_enabled) { status = rcl_logging_rosout_fini();