Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 07 Oct 2004 21:36:13 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        marc@msys.ch
Cc:        dnelson@allantgroup.com
Subject:   Re: syslog() reentrant when compiling with -pthread?
Message-ID:  <20041007.213613.34762646.imp@bsdimp.com>
In-Reply-To: <A3E829CE-1820-11D9-AB94-003065F9345A@msys.ch>
References:  <FFEC3743-17A3-11D9-BB63-0003938168B2@msys.ch> <20041006144800.GB87201@dan.emsphone.com> <A3E829CE-1820-11D9-AB94-003065F9345A@msys.ch>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <A3E829CE-1820-11D9-AB94-003065F9345A@msys.ch>
            Marc Balmer <marc@msys.ch> writes:
: Am 06.10.2004 um 16:48 schrieb Dan Nelson:
: 
: > The only unsafe part is openlog(), so set that up before you start any
: > threads and you'll be okay.  Once the log fd is opened, the syslog()
: > call looks to be thread-safe.  Everything in there is done with local
: > variables and atomic writes.
: 
: At least on OpenBSD I can use "%m" in the syslog() format string.  This 
: results in a call to strerror(), which is not thread safe, AFAIK.  This 
: probably is true for FreeBSD as well, so we have the following three 
: conditions for thread safe syslog():
: 
: 1) openlog() must be called before any threads that use syslog() are 
: started.
: 2) The first argument to openlog() must not be NULL.
: 3) The "%m" Format String must not be used in syslog() calls.
: 
: Any comments?

strerror is thread safe, unless your errno is outside of the valid
range.

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041007.213613.34762646.imp>