home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!gumby!yale!mintaka.lcs.mit.edu!bloom-picayune.mit.edu!daemon
- From: tytso@ATHENA.MIT.EDU (Theodore Ts'o)
- Subject: Re: Return from signal handler??
- Message-ID: <1992Aug13.014830.28283@athena.mit.edu>
- Sender: daemon@athena.mit.edu (Mr Background)
- Reply-To: tytso@ATHENA.MIT.EDU (Theodore Ts'o)
- Organization: The Internet
- Date: Thu, 13 Aug 1992 01:48:30 GMT
- Lines: 30
-
- From: Philip Balister <balister@pdsrvr.salem.ge.com>
- Reply-To: balister@pdsrvr.salem.ge.com
- Date: Wed, 12 Aug 1992 19:52:05 GMT
-
- A guy where I work is trying to use the signal mechanism of Lynxos to set
- a global variable to indicate a floating point error by trapping floating
- point exceptions signals. What he found was that the signal handler seems
- to return to the line that caused the signal, causing it to happen again,
- not what he wanted!
-
- That is in fact the correct behavior. If you catch something like a
- segmentation violation or a FP exception, it is up to your signal
- handler to either fix the registers or otherwise make sure that the
- problem won't happen again before you return. Most signal handlers for
- SEGV and FPE just do some cleanup work and then exit(); they do not
- return back to the program.
-
- An exception to this is how old versions of the Bourne shell did memory
- management. Malloc() would just hand out memory allocations without
- actually doing anything to make sure that the memory was there. Then,
- the first time the bourne shell tried to use the pointer, it would get a
- SIGV, which was trapped by a signal handler. That signal handler then
- did the sbrk() command so that the faulting instruction would success
- this time around, and returned.
-
- Needless to say, this was horrible design and not particularily portable
- to other platforms. But it illustrates the rare example of where you
- actually return from a signal handler for SIGSEGV or SIGFPE.
-
- - Ted
-