home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!think.com!paperboy.osf.org!meissner
- From: meissner@osf.org (Michael Meissner)
- Subject: Re: longjmp() from a signal handler
- In-Reply-To: tasos@cs.bu.edu's message of 27 Jan 93 18:04:05 GMT
- Message-ID: <MEISSNER.93Jan28145116@tiktok.osf.org>
- Sender: news@osf.org (USENET News System)
- Organization: Open Software Foundation
- References: <rturner.727977268@imagen> <1993Jan26.132457.26298@g2syd.genasys.com.au>
- <rturner.728076215@imagen> <108515@bu.edu>
- Date: 28 Jan 93 14:51:16
- Lines: 28
-
- In article <108515@bu.edu> tasos@cs.bu.edu (Anastasios Kotsikonas) writes:
-
- | In article <rturner.728076215@imagen> rturner@imagen.com (Randy Turner) writes:
- | # the the jmp_buf[] references. The POSIX.1 spec says that only a subset
- | # of library calls are safe to call from inside a signal handler, and the
- | # longjmp()/siglongjmp() calls are not among them. I was curious if
- | # Sys-V/R4 supports longjmp'ing from a signal handler, or is anyone has
- | # code that does this?
- |
- | Yes it does support it and it works fine; the same code actually works fine
- | on SUN/HP/IBM/SGI/Stardent/DG under BSD, SVR3 and SVR4.
-
- However this discussion is missing the main point (at least as far as
- I'm concerned) about longjmp'ing from within signal handlers. Because
- signals are delivered asynchronously, you could be in the library (or
- your own code), and be interrupted at the wrong time. For example,
- consider an implementation of malloc that uses a doubly linked list to
- hold the free list. If you are in the middle of calling malloc, your
- function may have updated one pointer, but was interrupted before the
- other pointer was stored. Thus your heap is now corrupted, but the
- symptoms may not show for a while, but when it does WHAMO. It may be
- that 999,999 times out of a million you are safe, but that doesn't
- mean you should blythly write code that fails at unpredictable times.
- --
- Michael Meissner email: meissner@osf.org phone: 617-621-8861
- Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
-
- You are in a twisty little passage of standards, all conflicting.
-