Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.unix.programmer Subject: Re: List of routines safe to use in signals? Message-ID: Date: 14 Dec 90 20:37:12 GMT References: <1960@necisa.ho.necisa.oz> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 38 In-reply-to: boyd@necisa.ho.necisa.oz's message of 11 Dec 90 23:39:52 GMT In article <1960@necisa.ho.necisa.oz> boyd@necisa.ho.necisa.oz (Boyd Roberts) writes: | In article rang@cs.wisc.edu (Anton Rang) writes: | > | > Anyway, is such a list available on the net somewhere? Lacking | >that, is there a reasonable heuristic to guess what's safe? | > ... | Set a flag in the signal handler and check for it elsewhere in | the code. Keep it simple and you won't get burned. Note that unless you are careful, even setting a flag may not be safe, if it takes more than one instruction to store the value. Off the top of my head, this can happen because of: 1) Using an int flag on an 8-bit micro, which requires 2 or more instructions to store the various pieces. 2) Using a char flag on a RISC machine which has no byte addressing modes, and does store bytes by loading the word, and/or-ing the value into place, and storing the word. 3) Using an int flag on a CISC machine which doesn't align things, the flag may span page boundaries, and you catch things in the middle of a page fault. ANSI specifies that the vendor must provide 'sig_atomic_t' in which it is guaranteed to be safe to store static/global flags from signal handlers. Using 'char' will proably work on most of the machines (but of course not all). -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET?