From owner-freebsd-questions Wed Jan 12 18:12:10 2000 Delivered-To: freebsd-questions@freebsd.org Received: from smtp6.mindspring.com (smtp6.mindspring.com [207.69.200.110]) by hub.freebsd.org (Postfix) with ESMTP id 0B47614E2F for ; Wed, 12 Jan 2000 18:09:43 -0800 (PST) (envelope-from stuyman@confusion.net) Received: from confusion.net (user-2ive64q.dialup.mindspring.com [165.247.24.154]) by smtp6.mindspring.com (8.9.3/8.8.5) with ESMTP id UAA08101 for ; Wed, 12 Jan 2000 20:34:22 -0500 (EST) Message-ID: <387D2B6C.4E2E42C1@confusion.net> Date: Wed, 12 Jan 2000 20:33:32 -0500 From: Laurence Berland Organization: B.R.A.T.T. X-Mailer: Mozilla 4.5 [en] (Win95; U) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG Subject: Re: Giving a sighandler more information References: <200001122054.VAA52051@dorifer.heim3.tu-clausthal.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Followup question: is a sig_atomic_t appropriate to hold the value of a FILE * ? Oliver Fromme wrote: > > Laurence Berland wrote in list.freebsd-questions: > > Oliver Fromme wrote: > >> Seriously. You _must_ declare global variables which are > >> accessed from a signal handler as ``volatile sig_atomic_t''. > >> Everything else is _not_ guaranteed to work (and if it works, > >> then it's just pure luck). > > > > Does this have something to do with the signal being caught while we're > > in the signal routine? Am I on the right track? > > No. The problem is that a signal handler can be called at > any time, basically, even in the midst of a memory access > (depending on the platform). The standard guarantees that > accesses to variables of type "sig_atomic_t" are always > atomic (hence the name), i.e. they cannot be interrupted > by a signal handler. > > The "volatile" qualifier makes sure that the compiler does > not try certain optimizations on these variables, such as > caching them in registers (which could also break signal > handlers, because the contents of the actual variable might > be incorrect if it's cached). > > Regards > Oliver > -- Laurence Berland, Stuyvesant HS Debate <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> Windows 98: n. useless extension to a minor patch release for 32-bit extensions and a graphical shell for a 16-bit patch to an 8-bit operating system originally coded for a 4-bit microprocessor, written by a 2-bit company that can't stand for 1 bit of competition. http://stuy.debate.net icq #7434346 aol imer E1101 The above email Copyright (C) 2000 Laurence Berland All rights reserved To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message