summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-11-12 12:14:38 -0500
committerDavid Thompson <dthompson2@worcester.edu>2015-11-12 12:14:38 -0500
commitefbd5d797af6ca36a61f225dc02ade47e8dfd175 (patch)
tree2aa860a534c97c2abadf24ea5dc65f3b4a5c9796
parentd6113f19673670320f79e880c236c6fcb760dd93 (diff)
game: Stop the game loop upon SIGINT.
Fixes a long standing annoyance that pressing C-c wouldn't kill the application. * sly/game.scm (run-game-loop): Catch SIGINT and call 'stop-game-loop'.
-rw-r--r--sly/game.scm5
1 files changed, 5 insertions, 0 deletions
diff --git a/sly/game.scm b/sly/game.scm
index ef92e90..b114ada 100644
--- a/sly/game.scm
+++ b/sly/game.scm
@@ -151,6 +151,11 @@ milliseconds of the last iteration of the game loop."
(call-with-prompt
'game-loop-prompt
(lambda ()
+ ;; Catch SIGINT and kill the loop.
+ (sigaction SIGINT
+ (lambda (signum)
+ (stop-game-loop)))
+ ;; Let's play!
(game-loop (SDL:get-ticks) 0))
(lambda (cont callback)
(when (procedure? callback)