Created
June 10, 2015 10:56
-
-
Save snmsts/87bb4e24dc37976a1b8d to your computer and use it in GitHub Desktop.
wait for safepoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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