Skip to content

Commit

Permalink
Update main.d
Browse files Browse the repository at this point in the history
* Correct ^C handling
* Correct ^C exit value
  • Loading branch information
abraunegg committed Apr 13, 2024
1 parent 295a734 commit dbe21ed
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -1406,22 +1406,14 @@ auto assumeNoGC(T) (T t) if (isFunctionPointer!T || isDelegate!T) {
return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t;
}

// Catch CTRL-C
// Catch CTRL-C if user pressed this
extern(C) nothrow @nogc @system void exitHandler(int value) {
try {
assumeNoGC ( () {
addLogEntry("Got termination signal, performing clean up");
// Force kill any running threads as ^C was used
taskPool.finish(false);
// Was itemDb initialised?
if (itemDB.isDatabaseInitialised()) {
// Make sure the .wal file is incorporated into the main db before we exit
addLogEntry("Shutting down DB connection and merging temporary data");
itemDB.performVacuum();
object.destroy(itemDB);
}
performStandardExitProcess();
})();
} catch(Exception e) {}
exit(0);
// Exit with the exitHandler value
exit(value);
}

0 comments on commit dbe21ed

Please sign in to comment.