This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Is syslog() with '%m' specifier thread safe?
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Patryk Bęza <patryk dot beza at gmail dot com>
- Cc: libc-help at sourceware dot org
- Date: Sun, 18 Sep 2016 16:29:35 +0200
- Subject: Re: Is syslog() with '%m' specifier thread safe?
- Authentication-results: sourceware.org; auth=none
- References: <bd9e496a-30fb-3b91-b86e-f5ce6314e420@gmail.com>
* 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.