D Exceptions
Steven Schveighoffer
schveiguy at yahoo.com
Tue Jan 26 12:19:20 PST 2010
On Tue, 26 Jan 2010 15:07:50 -0500, Nick Sabalausky <a at a.a> wrote:
> "Daniel Keep" <daniel.keep.lists at gmail.com> wrote in message
> news:hjn49d$2kfe$1 at digitalmars.com...
>>
>>
>> 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
More information about the Digitalmars-d
mailing list