home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!jit081.enet.dec.com!diamond
- From: diamond@jit081.enet.dec.com (01-Sep-1992 1245)
- Newsgroups: comp.std.c
- Subject: Re: ANSI description for signal handling
- Message-ID: <9209010345.AA20605@enet-gw.pa.dec.com>
- Date: 1 Sep 92 03:45:58 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Lines: 48
-
- In article <9208311827.AA10025@ucbvax.Berkeley.EDU> JENNIFER@TOROLAB6.VNET.IBM.COM ("Jennifer Hamilton") writes:
- >( ... also posted to comp.lang.c)
-
- In order to do that, you should edit the "Newsgroups:" line in the header
- to say "Newsgroups: comp.std.c,comp.lang.c" instead of posting two
- separate articles.
-
- >In the ANSI standard under the description of the signal function,
- >(section 4.7.1.1) it states the following:
- > "The function func may terminate by executing a return statement or
- > by calling the abort, exit, or longjmp functions. If func executes a
- > return statement and the value of sig was SIGFPE or any other
- > implementation-defined value corresponding to a computational
- > exception, the behaviour is undefined. Otherwise, the program will
- > resume execution at the point it was interrupted. If the signal
- > occurs other than as the result of calling the abort or raise
- > function, the behaviour is undefined if the signal handler calls any
- > function in the standard library other than the signal function
- > itself ..."
- >The last sentence implies that you can't call any library functions
- >(such as longjmp, abort or exit) from within the signal handler unless
- >the signal was explicitly raised through raise or abort.
-
- That is correct. (However, even when the standard explicitly leaves the
- behavior undefined, an implementation is still allowed to define an
- extension if it wishes, and a non-strictly conforming program is allowed
- to take advantage of the extension, though it won't be portable.)
-
- >But the first three sentences imply that you can.
-
- Well, yes and no. It does seem worded to raise false hopes before quashing
- them. However, it doesn't exactly say that func may call abort, exit, or
- longjmp under all circumstances. The only "standard" circumstance under
- which a signal may be received is due to calling abort or raise, and under
- this circumstance, there are four defined methods of exiting. If a signal
- is received due to implementation extensions, then the standard says that
- the implementation still has to allow an ordinary return statement, but
- doesn't have to allow other means of exit from the handler.
-
- Now, one might wonder if SIGPFE, SIGILL, SIGINT, SIGSEGV, or SIGTERM might
- also be "standard" circumstances for signals to be received. Well, the
- standard says "An implementation need not generate any of these signals,
- except as a result of explicit calls to the raise function." So even though
- these macros exist, they do not have "standard" defined meanings.
- --
- Norman Diamond diamond@jit081.enet.dec.com
- If this were the company's opinion, I wouldn't be allowed to post it.
- "Yeah -- bad wiring. That was probably it. Very bad."
-