Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!zen.net.uk!dedekind.zen.co.uk!reader02.nrc01.news.zen.net.uk.POSTED!not-for-mail From: Nobody Subject: Re: Safe accesses of global arrays in signal handlers? Date: Thu, 27 Sep 2012 13:35:55 +0100 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.programming.threads,comp.unix.programmer References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines: 21 Organization: Zen Internet NNTP-Posting-Host: 89eb1185.news.zen.co.uk X-Trace: DXC=EdAHmY7]j9binCmPbdZEoc]G;bfYi23hd=dR0\ckLKG`WeZ<[7LZNRf^HFbc]gFA^bNQ<`Sf8^TaoHEX9XA2;2ShjMF[@JSMFif X-Complaints-To: abuse@zen.co.uk Xref: csiph.com comp.programming.threads:1098 comp.unix.programmer:3347 On Thu, 27 Sep 2012 11:20:14 +0200, Markus Elfring wrote: >> The recommended way to handle signals is to block all relevant async >> signals in all threads, then have a single thread which does nothing but >> poll signals using sigwaitinfo() then handle them (e.g. by notifying >> condition variables, appending information to a queue, etc). > > Do you know any other solutions which can work without such an initial signal > blockage like it is needed in the suggested approach for the handling of > real-time systems? Doing anything substantial in a signal handler is problematic. So typically you just want to notify a thread which blocks until notification. There are a few async-signal-safe functions which can be used for notification, including sem_post(), sigqueue(), raise() and write(). A complete list is at: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03 Note that none of the pthread functions are in that list.