From 44edb6bdd2edc48eb31ed160a09006b610cead67 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 14 May 2003 14:21:30 +0000 Subject: Add support for atexit function, remove support for __main function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6194 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/Interpreter/Interpreter.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'lib/ExecutionEngine/Interpreter/Interpreter.cpp') diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/lib/ExecutionEngine/Interpreter/Interpreter.cpp index 4582a6f26d..3453d83195 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -48,10 +48,21 @@ int Interpreter::run(const std::string &MainFunction, run(); } - // If debug mode, allow the user to interact... also, if the user pressed - // ctrl-c or execution hit an error, enter the event loop... - if (Debug || isStopped()) - handleUserInput(); + do { + // If debug mode, allow the user to interact... also, if the user pressed + // ctrl-c or execution hit an error, enter the event loop... + if (Debug || isStopped()) + handleUserInput(); + + // If the program has exited, run atexit handlers... + if (ECStack.empty() && !AtExitHandlers.empty()) { + callFunction(AtExitHandlers.back(), std::vector()); + AtExitHandlers.pop_back(); + run(); + } + } while (!ECStack.empty()); + + PerformExitStuff(); return ExitCode; } -- cgit v1.2.3-18-g5258