From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: Re: [Xen-changelog] Make xenstored reopen its trace file on SIGHUP. This allows one to rotate the Date: Mon, 07 Nov 2005 11:36:53 -0600 Message-ID: <436F90B5.2040607@us.ibm.com> References: <436F8BB6.1090207@us.ibm.com> <200511071124.02430.hollisb@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <200511071124.02430.hollisb@us.ibm.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Hollis Blanchard Cc: xen-devel@lists.xensource.com, Ewan Mellor List-Id: xen-devel@lists.xenproject.org Hollis Blanchard wrote: >On Monday 07 November 2005 11:15, Anthony Liguori wrote: > > >>perror and strlen are not safe to call from a signal handler. >> >>I suggest just removing the perror call altogether and replacing strlen >>with sizeof() - 1. >> >> > >I'm really not sure how strlen could be non-threadsafe. I don't care if it's >not in your list; your list doesn't include strtok_r either, and that is >explicitly thread-safe. :-P > > So re-reading the manpage, the list of safe functions is a POSIX-ism. That's perhaps why the thread-safe string functions aren't there since those are defined by ANSI not POSIX. Regards, Anthony Liguori >However, in addition to perror, another thread could try to use tracefd >between the close and the open. You'd probably want to do something like: > oldfd = tracefd; > newfd = open(); > if (newfd < 0) { > ... > } > tracefd = newfd; > close(oldfd); > >Finally, you really should do error-checking on close(). See the close(2) man >page... > > >