D Exceptions

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Tue Jan 26 11:56:54 PST 2010


Steve Teale wrote:
> Daniel Keep Wrote:
> 
>>
>> Steve Teale wrote:
>>> ...
>>>
>>> So it seems there is a safety net in Windows, but not in Linux. Is this how it is supposed to be?
>> Under Windows, access violations cause the OS to throw an exception.
>> Since D uses the same EH mechanism as the OS, this integrates nicely.
>>
>> Under linux, SIGSEGV is a signal, and you can't safely throw exceptions
>> from signal handlers, so D just aborts.
>>
>> As far as I understand it, it's a limitation of the way linux is designed.
> 
> Thanks Daniel, now I've had time to get something to eat and a couple of beers, that makes complete sense.
> 
> So basically, under Linux, there's not much your program can do to protect itself against errors in library code, right?

Well, you can intercept signals, but it requires you to get down and 
dirty with some C-style programming:

   http://agenda.ictp.trieste.it/agenda_links/smr1335/rt2001/node8.html

The relevant modules are:
   D1:  std.c.linux.linux
   D2:  core.sys.posix.signal

-Lars



More information about the Digitalmars-d mailing list