summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libutil.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-10-30 21:59:59 +0100
committerAdam Borowski <kilobyte@angband.pl>2013-11-25 23:47:49 +0100
commit5f077547fa1719e85543b7c6734a251bd364a680 (patch)
tree4bf512805eeaacfeb997ea487e8ea643f32913e4 /crawl-ref/source/libutil.cc
parent836b35dd65790f235e782529e43b8fd3f7bfd798 (diff)
downloadcrawl-ref-5f077547fa1719e85543b7c6734a251bd364a680.tar.gz
crawl-ref-5f077547fa1719e85543b7c6734a251bd364a680.zip
Allow graceful shutdown rather than a forced save (win32 console).
This injects a fake key code into the input stream, making the syscall return. The pseudo-signal handler thread will then wait forever (for a value of "forever" of 15 seconds).
Diffstat (limited to 'crawl-ref/source/libutil.cc')
-rw-r--r--crawl-ref/source/libutil.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc
index 3beb1363e2..d84110f2f7 100644
--- a/crawl-ref/source/libutil.cc
+++ b/crawl-ref/source/libutil.cc
@@ -1195,14 +1195,11 @@ static BOOL WINAPI console_handler(DWORD sig)
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
if (crawl_state.seen_hups++)
- return true;
+ return true; // abort immediately
+
+ w32_insert_escape();
- // SAVE CORRUPTING BUG!!! We're in a sort-of-a-signal-handler here,
- // unlike Unix which processes signals as an interrupt, Windows spawns
- // a new thread to handle them. This function will try to save the
- // game when it is likely to be in an inconsistent state -- and even
- // worse, the main thread is actively changing data structures.
- sighup_save_and_exit();
+ Sleep(15000); // allow 15 seconds for shutdown, then kill -9
return true;
}
}