aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/Interpreter/Interpreter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/Interpreter.cpp')
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.cpp19
1 files changed, 15 insertions, 4 deletions
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<GenericValue>());
+ AtExitHandlers.pop_back();
+ run();
+ }
+ } while (!ECStack.empty());
+
+ PerformExitStuff();
return ExitCode;
}