Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!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: 11 Dec 90 20:47:44 GMT References: Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 33 In-reply-to: rang@cs.wisc.edu's message of 11 Dec 90 04:17:47 GMT In article rang@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@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?