List of routines safe to use in signals?

Michael Meissner meissner at osf.org
Wed Dec 12 07:47:44 AEST 1990


In article <RANG.90Dec10231747 at nexus.cs.wisc.edu> rang at cs.wisc.edu
(Anton Rang) writes:

|   Is there a list of library routines which can safely be used within
| a signal handler under any of the "standard" UNIX versions (preferably
| POSIX, but I'd like BSD 4.3 and SVR4 info as well)?  Presumably this
| is in the POSIX standard, but if anybody has an online copy of such a
| list, I'd appreciate it.
| 
|   So far, I know to avoid functions which use static areas of memory
| for their return value (e.g. getpwent), and I avoid the standard I/O
| routines (e.g. fprintf) unless I know that the file won't have other
| I/O going on at the time.  I also save and restore errno, which is
| perhaps overkill....
| 
|   Anyway, is such a list available on the net somewhere?  Lacking
| that, is there a reasonable heuristic to guess what's safe?

Here is the complete list:

	signal (or sigaction)  to set up the signal handler again.

That's it.  You may think something's safe, but it may be in the
middle of a malloc call or what have you.  Without having the library
do a sigblock around every single critical area (and then being slow
as molosses in january) there is no safe list of routines.  Either
rewrite your code not to call ANYTHING from a signal handler, or be
prepared to have it fail occasionally in unpredicatible areas.
--
Michael Meissner	email: meissner at 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?



More information about the Comp.unix.programmer mailing list