Terminating an application
Sean Kelly
sean at f4.ca
Wed Sep 12 22:11:10 PDT 2007
Mike Parker wrote:
> llee wrote:
>> Is it possible to terminate an application after catching an
>> exception|error? I know how that assert will automatically terminate
>> an application after catching an AssertError. Is there a general
>> method for terminating an application outside of main(). Perhaps,
>> something like exit() under linux?
>
> If you rethrow the exception, or throw a new one, and let it propagate
> up the app will exit.
Assuming the exception is thrown from the main thread. And assuming
you're either using Phobos or are using Tango and have no non-daemon
threads running. So far, the best alternative I've come up with is to
register the routines you'd normally call manually when exiting a DLL
with atexit, and then call the C exit routine. I've been considering
doing basically this in a repackaged Runtime.exit(int) routine in Tango.
Sean
More information about the Digitalmars-d
mailing list