aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.lisp
diff options
context:
space:
mode:
authorTeddy Wing2022-05-21 18:48:09 +0200
committerTeddy Wing2022-05-21 18:56:58 +0200
commit165af78b4f7955870d0b3f6dd029768380661be4 (patch)
treef022637205683306024df348a3b9c787cd9924d2 /src/main.lisp
parent3307447f4a5c361fc2812244cd20c3bbe9a91bdc (diff)
downloadwajir-165af78b4f7955870d0b3f6dd029768380661be4.tar.bz2
main: Exit on Control-c
Use `with-user-abort` to exit on a Control-c SIGINT. Used the following tutorial for inspiration: https://stevelosh.com/blog/2021/03/small-common-lisp-cli-programs/#s12-errors Apparently Control-c should exit with code 130 according to this: https://tldp.org/LDP/abs/html/exitcodes.html Followed these Stack Overflow answers to turn off the interactive debugger in an implementation independent way: https://stackoverflow.com/questions/3074586/how-to-turn-off-the-debugger-in-sbcl/3074698#3074698 https://stackoverflow.com/questions/69280179/unmatched-close-parenthesis-when-sbcl-debugger-is-turned-off This still opens the interactive debugger if Control-c is pressed before `(main)` is called, but I don't know if there's any way to prevent that.
Diffstat (limited to 'src/main.lisp')
-rw-r--r--src/main.lisp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/main.lisp b/src/main.lisp
index bd1e774..6076da7 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -1,7 +1,5 @@
(in-package :wajir)
-(defparameter uiop:*lisp-interaction* nil)
-
(defun main ()
;; Query page of issues
;; Start watching issue
@@ -10,8 +8,31 @@
;; TODO: Add SIGINT and error handling
- (let ((config (parse-options)))
- (run config)))
+ ;; Disable interactive debugger.
+ ; (defparameter uiop:*lisp-interaction* nil)
+ (setf *debugger-hook* #'debug-ignore)
+
+ (handler-case
+ (interrupt:with-user-abort
+ (handler-bind ((error #'(lambda (e)
+ (exit-with-error e sysexits:+unavailable+))))
+
+ ; (let ((config (parse-options)))
+ ; (run config))
+
+ (format t "l-i: ~S~%" uiop:*lisp-interaction*)
+ (format t "main ran~%")
+ (sleep 5)))
+
+ ;; Control-c
+ (interrupt:user-abort ()
+ (format t "siginted~%")
+ (opts:exit 130))))
+
+(defun debug-ignore (condition hook)
+ (declare (ignore hook))
+ (princ condition)
+ (abort))
(defun run (config)
(let ((basic-auth-token (cl-base64:string-to-base64-string