(declare (uses srfi-18)) (define (logerr . args) (apply format (current-error-port) args) (flush-output (current-error-port)) (format (current-error-port) "let's do some garbage\n") (flush-output (current-error-port)) (let ((s "")) (do ((i 0 (+ i 1))) ((eqv? i 20000) #t) (set! s (string-append s (number->string i))))) (format (current-error-port) "enough garbage\n") (flush-output (current-error-port))) (define (with-timeout timeout thunk) (let ((thread (thread-start! (make-thread thunk ;; (string-append (thread-name (current-thread)) "-worker") )))) (thread-sleep! timeout) (thread-terminate! thread))) (define (test2) (handle-exceptions ex (begin (logerr "error ~a\n" ex) #f) (with-timeout 3 (lambda () (do () (#f) #t))))) (print "test") (test2) (logerr "done\n") (exit 0)