From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 7 05:45:22 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF79D16A4CE for ; Thu, 7 Oct 2004 05:45:22 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 99B4243D46 for ; Thu, 7 Oct 2004 05:45:22 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.11/8.12.11) id i975jMci022871; Thu, 7 Oct 2004 00:45:22 -0500 (CDT) (envelope-from dan) Date: Thu, 7 Oct 2004 00:45:22 -0500 From: Dan Nelson To: Marc Balmer Message-ID: <20041007054521.GA7104@dan.emsphone.com> References: <20041006144800.GB87201@dan.emsphone.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 5.3-BETA7 X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: freebsd-hackers@freebsd.org Subject: Re: syslog() reentrant when compiling with -pthread? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2004 05:45:23 -0000 In the last episode (Oct 07), Marc Balmer said: > 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. 4) make syslog() use strerror_r() Actually, for known errno values, strerror() is thread-safe on FreeBSD. It just returns a pointer into sys_errlist[]. For invalid values it stuffs "Unknown error: ##" into a static buffer and returns a pointer to that. I'll update the PR to make syslog call strerror_r(). http://www.freebsd.org/cgi/query-pr.cgi?pr=standards/72394 -- Dan Nelson dnelson@allantgroup.com