From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 7 05:20:56 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 2CF2D16A4CE for ; Thu, 7 Oct 2004 05:20:56 +0000 (GMT) Received: from bragi.msys.ch (bragi.msys.ch [157.161.101.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8DC2A43D60 for ; Thu, 7 Oct 2004 05:20:55 +0000 (GMT) (envelope-from marc@msys.ch) Received: from [192.168.17.16] (merlin.etc.msys.ch [213.189.137.178]) i975KkVp009463; Thu, 7 Oct 2004 07:20:46 +0200 In-Reply-To: <20041006144800.GB87201@dan.emsphone.com> References: <20041006144800.GB87201@dan.emsphone.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Marc Balmer Date: Thu, 7 Oct 2004 07:20:45 +0200 To: Dan Nelson X-Mailer: Apple Mail (2.619) 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:20:56 -0000 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? - Marc