Recently Written · git

clic

MIRROR ONLY Gopher client with pretty colours in Common Lisp

git clone https://github.com/equwal/clic

Log | Files | Refs


commit 22248dc9ab2895d7bcf8b3bcfcf76eb48ecc075f
Solene Rapenne <solene@perso.pw>
2018-06-21 11:05:17 +0200

Forbid escaping clic loading with SIGINT

 clic.lisp        | 12 ++++++++----
 make-binary.lisp |  6 +++++-
 2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/clic.lisp b/clic.lisp
index f2e7eeb..d11256e 100644
--- a/clic.lisp
+++ b/clic.lisp
@@ -571,10 +571,8 @@
          ;; split and ask to scroll or to type a command
            (when (= row rows)
              (setf row 0)
-             (format t "~a~a   press enter or a shell command ~a : "
-                     (get-color 'bg-black)
-                     (if *kiosk-mode* "KIOSK" "")
-                     (get-color 'reset))
+             (format t "~a   press enter or a shell command: "
+                     (if *kiosk-mode* "KIOSK" ""))
              (force-output)
              (let ((first-input (read-char *standard-input* nil nil t)))
                (cond
@@ -735,7 +733,13 @@
   with a parameter not of type 1, so it will fetch the content,
   display it and exit and finally, the redirected case where clic will
   print to stdout and exit."
+
+  ;; pledge support on OpenBSD
   (c-pledge)
+
+  ;; re-enable SIGINT (Ctrl+C) disabled for loading clic
+  (ext:set-signal-handler ext:+sigint+ 'quit)
+
   (ignore-errors ;; lisp is magic
     (let ((destination (car (last
                              (loop for element in (get-argv)
diff --git a/make-binary.lisp b/make-binary.lisp
index f2048ce..2211b93 100644
--- a/make-binary.lisp
+++ b/make-binary.lisp
@@ -7,7 +7,11 @@
 #+ecl
 (progn
   (compile-file "clic.lisp" :system-p t)
-  (c:build-program "clic" :epilogue-code '(progn (handler-case (main)  (condition () (quit)))) :lisp-files '("clic.o")))
+  (c:build-program "clic"
+                   :prologue-code '(ext:set-signal-handler ext:+sigint+ nil)
+                   :epilogue-code '(progn (handler-case (main)
+                                            (condition () (quit))))
+                   :lisp-files '("clic.o")))
 
 (format t "INFO => Compilation done (or at least it should be)~%")
 (quit)