Is syslog() with '%m' specifier thread safe?
Florian Weimer
fw@deneb.enyo.de
Sun Sep 18 14:29:00 GMT 2016
* Patryk Bęza:
> Is syslog() with '%m' specifier thread safe (as strerror_r is)?
Let's word it this way: If it is not thread-safe, it is not due to the
use of the %m specifier.
syslog eventually calls into stdio-common/vfprintf.c, which does:
LABEL (form_strerror): \
/* Print description of error ERRNO. */ \
string = \
(CHAR_T *) __strerror_r (save_errno, (char *) work_buffer, \
WORK_BUFFER_SIZE * sizeof (CHAR_T)); \
is_long = 0; /* This is no wide-char string. */ \
goto LABEL (print_string)
But then, strictly speaking, strerror_r (and therefore %m) is not
thread-safe because it accesses the global locale object in an
unsynchronized fashion.
More information about the Libc-help
mailing list