diff --git a/drivers/syslog/syslog_write.c b/drivers/syslog/syslog_write.c index 2573384050e34..0640a0bf2bf02 100644 --- a/drivers/syslog/syslog_write.c +++ b/drivers/syslog/syslog_write.c @@ -37,6 +37,39 @@ * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: syslog_safe_to_block + * + * Description: + * Check if it is safe to block for write. If not, the write defaults to a + * non-blocking method. + * + * Input Parameters: + * None. + * + * Returned Value: + * true if it is safe to block; false otherwise. + * + ****************************************************************************/ + +static bool syslog_safe_to_block(void) +{ + FAR const struct tcb_s *rtcb; + + if (up_interrupt_context() || sched_idletask()) + { + return false; + } + + rtcb = nxsched_self(); + if (rtcb->sigdeliver != NULL) + { + return false; + } + + return true; +} + /**************************************************************************** * Name: syslog_default_write * @@ -59,7 +92,7 @@ static ssize_t syslog_default_write(FAR const char *buffer, size_t buflen) { size_t nwritten; - if (up_interrupt_context() || sched_idletask()) + if (!syslog_safe_to_block()) { #ifdef CONFIG_SYSLOG_INTBUFFER if (up_interrupt_context())