Topic: Signals and exceptions?


Author: Tom Payne <thp@hill.cs.ucr.edu>
Date: 1999/09/01
Raw View
Christopher Eltschka <celtschk@physik.tu-muenchen.de> wrote:
[...]
: What if a signal happens in destructor code?
: Note that signals do not just occur in cases like division
: by zero, but also in various really asynchronous cases,
: like SIGPIPE.

: Also, signals are not only used for error cases.
: For example, Unix systems can cause an exception (SIGCHILD)
: if a child process terminates. You certainly do not want
: an exception thrown at this event. Another signal is
: SIGWINCH, which is sent if the xterm size changes.
: Again, I doubt anyone would like an exception to be
: thrown here. And the ultimate non-error: SIGIO - I/O now
: possible.

It would clearly be inappropriate for every signal to turn into an
exception, but it would be nice for signal handlers to be able to
throw exceptions.  I agree, however, that an acceptly efficient
implementation of such a feature would be difficult if not impossible.
(Per the C Standard, signal handlers can't portably read global
variables.  Nor can they call functions of the standard library.
And SIGFPE's handler can't even return.)

Tom Payne
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]