> So there is two things with signals. First, when a process get a signal > queued, the OS only deliver the signal -- at least on linux -- when > going back to user-space. Typically, before the process get > re-scheduled or after a system call. So sending a signal is not > immediate. Furthermore, Guile also queues the signals and deliver them > to threads with async marks I think.
I understand. I don't get this problem with C, so I assume it's the asynchronity of Guile that is my issue. I tried running the scm_async_tick function, which the documentation says runs queued asyncs (by providing a 'safe point', but that doesn't seem to change anything. (define-module (testing) #:use-module (system foreign) #:use-module (system foreign-library)) (define tick (foreign-library-function #f "scm_async_tick")) (define quit? #f) (sigaction SIGINT (lambda (arg) (pk "SIG" arg) (set! quit? #t))) (let loop () (pk "QUIT-CHECK") (tick) (if quit? (begin (format #t "Quitting!~%") (exit 0)) (begin (pk "WORK" (do ((i 0 (+ i 1)) (sum 0 (+ sum i))) ((= i 1000) sum))) (let ((ret (sleep 10))) (pk "SLEEP" ret) (loop))))) ~ Vijay