Steven Schveighoffer wrote:
On Tue, 26 Jan 2010 15:07:50 -0500, Nick Sabalausky <[email protected]> wrote:
"Daniel Keep" <[email protected]> wrote in message
news:[email protected]...
Under linux, SIGSEGV is a signal, and you can't safely throw exceptions
from signal handlers, so D just aborts.
Just out of curiosity, is that a limitation that comes from the basic
concept of signals, or just a detail of how the OS just happens to do
signals?
I think it's because a signal handler is entered at any point in the
call stack. This means that to unwind the stack, you need to unwind
possibly C functions and (I think) even system calls. The safest thing
to do in a signal handler is to set a flag indicating a signal was
recieved, and then asynchronously process it.
Given that you could be in C or C++ land where exceptions either don't
exist or are different, you face a very difficult task to unwind the
stack correctly.
-Steve
Yah it's the asynchrony of signals. Exceptions are synchronous, which
makes them a great deal simpler than they otherwise could.
Andrei