digitalmars.D - Terminating an application
- llee (1/1) Sep 12 2007 Is it possible to terminate an application after catching an exception|e...
- Bill Baxter (5/6) Sep 12 2007 exit() is defined in std.c.stdlib. Selective import is good to avoid
- llee (2/11) Sep 12 2007 Thanks.
- Jarrett Billingsley (10/12) Sep 12 2007 Sadly, exit() will not unwind the stack, calling scope blocks and destro...
-
Stewart Gordon
(5/13)
Sep 13 2007
"Jarrett Billingsley"
wrote in message - Jarrett Billingsley (4/5) Sep 13 2007 Exceptions in flight cause scope(failure) blocks to execute. Exiting an...
- Mike Parker (3/4) Sep 12 2007 If you rethrow the exception, or throw a new one, and let it propagate
- Sean Kelly (8/17) Sep 12 2007 Assuming the exception is thrown from the main thread. And assuming
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?
Sep 12 2007
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?exit() is defined in std.c.stdlib. Selective import is good to avoid polluting your namespace with all the other cruft in stdlib: import std.c.stdlib : exit; --bb
Sep 12 2007
Bill Baxter Wrote:llee wrote:Thanks.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?exit() is defined in std.c.stdlib. Selective import is good to avoid polluting your namespace with all the other cruft in stdlib: import std.c.stdlib : exit; --bb
Sep 12 2007
"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message news:fc9oc2$2dsc$1 digitalmars.com...exit() is defined in std.c.stdlib. Selective import is good to avoid polluting your namespace with all the other cruft in stdlib:Sadly, exit() will not unwind the stack, calling scope blocks and destroying scope instances. It also will not call any of the runtime cleanup functions (calling module dtors, closing the GC, anything else the RT wants to do) without explicitly telling it to with atexit(). So, it's not a very robust situation for the general case. I'd be _very_ interested how one could solve this without throwing an exception that you catch in main. Perhaps it's another runtime function that is necessary, one that'll unwind the stack but without an exception.
Sep 12 2007
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message news:fc9q1j$2gr8$1 digitalmars.com... <snip>Sadly, exit() will not unwind the stack, calling scope blocks and destroying scope instances. It also will not call any of the runtime cleanup functions (calling module dtors, closing the GC, anything else the RT wants to do) without explicitly telling it to with atexit(). So, it's not a very robust situation for the general case. I'd be _very_ interested how one could solve this without throwing an exception that you catch in main. Perhaps it's another runtime function that is necessary, one that'll unwind the stack but without an exception.What's the point of trying to avoid using an exception? Stewart.
Sep 13 2007
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:fccpeg$2qdo$1 digitalmars.com...What's the point of trying to avoid using an exception?Exceptions in flight cause scope(failure) blocks to execute. Exiting an app deep in the call stack is not necessarily a failure condition.
Sep 13 2007
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.
Sep 12 2007
Mike Parker wrote:llee wrote: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. SeanIs 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.
Sep 12 2007