summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/stuff.cc
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-10 02:01:09 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-10 02:13:09 -0800
commit2ebed5e396b655383be577ec55cfb756fcf328d4 (patch)
tree537412a06f2c32ee61ce99eef56a839dfcba8367 /crawl-ref/source/stuff.cc
parent4bd335dab6488ac58d412f8b640801350207c398 (diff)
downloadcrawl-ref-2ebed5e396b655383be577ec55cfb756fcf328d4.tar.gz
crawl-ref-2ebed5e396b655383be577ec55cfb756fcf328d4.zip
Brief crash output for exit() crashes
If a crash happens while exit() callbacks are being processed then just output a bare minimum of info to stderr, since anything we might want to reference would likely have been free'd, and we don't want to reference free'd memory (plus information about the player, level and monsters probably won't be of any help in tracking down a crash of that kind).
Diffstat (limited to 'crawl-ref/source/stuff.cc')
-rw-r--r--crawl-ref/source/stuff.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 9ca0204e12..d7f211bdea 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -356,6 +356,12 @@ void clear_globals_on_exit()
clear_zap_info_on_exit();
}
+// Used by do_crash_dump() to tell if the crash happened during exit() hooks.
+// Not a part of crawl_state, since that's a global C++ instance which is
+// free'd by exit() hooks when exit() is called, and we don't want to reference
+// free'd memory.
+bool CrawlIsExiting = false;
+
void end(int exit_code, bool print_error, const char *format, ...)
{
std::string error = print_error? strerror(errno) : "";
@@ -395,6 +401,7 @@ void end(int exit_code, bool print_error, const char *format, ...)
}
#endif
+ CrawlIsExiting = true;
exit(exit_code);
}