Skip to content

Instantly share code, notes, and snippets.

@snmsts
Created June 10, 2015 10:56
Show Gist options
  • Save snmsts/87bb4e24dc37976a1b8d to your computer and use it in GitHub Desktop.
Save snmsts/87bb4e24dc37976a1b8d to your computer and use it in GitHub Desktop.
wait for safepoint
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -L sbcl -- $0 "$@"
|#
(ql:quickload :bordeaux-threads)
(defvar *should-finish* nil)
(defvar *finished* nil)
(defun worker ()
(loop :while t
:do (loop :for i :from 0 :below 10
:do (sleep 1)
(princ i)
(force-output)
:finally (terpri))
:until *should-finish*)
(setf *finished* t))
(defun main (&rest argv)
(declare (ignorable argv))
(bt:make-thread #'worker :name "worker")
(format t "worker launched wait for sigint ~%PID:~A~%"(sb-posix:getpid))
(loop
:do (handler-case
(progn
(loop :while t
:do (sleep 1)
:until *finished*))
(sb-sys:interactive-interrupt (condition)
(declare (ignore condition))
(print "sigint!")
(setq *should-finish* t)))
:until *finished*))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment