home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!spillman!tye
- From: tye@spillman.uucp (E. Tye McQueen)
- Subject: Re: longjumping out of a signal handler
- Message-ID: <1992Dec14.223422.39678@spillman.uucp>
- Date: Mon, 14 Dec 1992 22:34:22 GMT
- References: <1992Dec7.121124.3737@cs.utwente.nl> <1992Dec8.113719.22463@cs.utwente.nl> <1992Dec09.185512.33137@spillman.uucp> <1992Dec11.120446.28991@cs.utwente.nl>
- Organization: Spillman Data Systems
- Lines: 39
-
- ahoekstr@cs.utwente.nl (Andre D. Hoekstra) writes:
- )But if your implementation of signal handlers blocks overrun signals by
- )setting a flag on entry in your signal handler, and clearing it on exit,
- )you may get stuck with a masked signal, by not exiting from the handler.
- )(longjump prevents exit/return obviously). Unless signal clears this
- )flag for the signal at hand explicitly you are unsafe.
-
- Well, it is nice to know that some (pre-ANSI?) system have this
- problem. Anyone have a list of *which* systems have this problem?
-
- K&R II doesn't talk about any of this and my copy of the standard
- is way outdated, so maybe I'm wrong; but I distinctly recall that
- ANSI guarantees only two things that can be done within a signal
- handler: 1) Set a variable of type "sig_atomic_t" and 2) Call
- longjump().
-
- If so, how do such systems conform to ANSI C? Does setjump() save
- the signal mask and longjump() restores it? Is there some require-
- ment that I reset the signal myself from within the handler before
- calling longjump()? Or is this just an OS "bug" that newer systems
- no longer have? (I mean, longjump(), if anything, is for exception
- handling as are signals so it doesn't make sense to design a system
- where they can't be used together.)
-
- I'm not arguing that using longjump() within a signal handler is in
- fact safe on all systems. It clearly is not. But I don't think
- setting a global flag in the signal handler and checking it in a
- calling routine will work on all systems either (see below).
-
- Anyone know which systems restart system calls for you in a way that
- prevents you from interrupting them with a caught signal so you can
- see if your "sig_atomic_t" flag has been set? Seems like this was a
- BSDism. Is this behavior disallowed by ANSI C, Posix, etc.?
-
- Thanks,
- tye@spillman.com Tye McQueen, E.
- ----------------------------------------------------------
- Nothing is obvious unless you are overlooking something.
- ----------------------------------------------------------
-