diff options
| -rw-r--r-- | src/main.lisp | 48 | ||||
| -rw-r--r-- | src/package.lisp | 3 | 
2 files changed, 30 insertions, 21 deletions
| diff --git a/src/main.lisp b/src/main.lisp index 01d78a1..d08b323 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -28,27 +28,33 @@    "Global timeout. The program will exit at the end of this delay.")  (defun main () -  (handler-bind ((error #'(lambda (e) -                            (exit-with-error e sysexits:+unavailable+)))) - -    ;; Store the config as a global. -    (defvar *config* (parse-options)) - -    (trivial-timeout:with-timeout (+timeout-seconds+) -      (with-websocket-connection ((ws-client *config*)) -        (wsd:on :message (ws-client *config*) -                #'(lambda (message) -                    (ws-on-message -                      message -                      (extension-ids *config*) -                      *config*))) - -        (websocket-send -          (ws-client *config*) -          (target-get-targets-msg -            (next-call-id *devtools-root-call-id*))) - -        (wait-group:wait *wg*))))) +  (handler-case +      (interrupt:with-user-abort +        (handler-bind ((error #'(lambda (e) +                                  (exit-with-error e sysexits:+unavailable+)))) + +          ;; Store the config as a global. +          (defvar *config* (parse-options)) + +          (trivial-timeout:with-timeout (+timeout-seconds+) +            (with-websocket-connection ((ws-client *config*)) +              (wsd:on :message (ws-client *config*) +                      #'(lambda (message) +                          (ws-on-message +                            message +                            (extension-ids *config*) +                            *config*))) + +              (websocket-send +                (ws-client *config*) +                (target-get-targets-msg +                  (next-call-id *devtools-root-call-id*))) + +              (wait-group:wait *wg*))))) + +    ;; Control-c +    (interrupt:user-abort () +      (opts:exit sysexits:+ok+))))  (defun ws-on-message (message extension-ids config)    "Called when a WebSocket message is received." diff --git a/src/package.lisp b/src/package.lisp index 9fa60e7..74e7949 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -18,4 +18,7 @@  (defpackage :extreload    (:use :cl) + +  (:local-nicknames (:interrupt :with-user-abort)) +    (:export :main)) | 
