This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Is syslog() with '%m' specifier thread safe?


* 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]