Hi, I know that the chicken core is not re entrant. In that context, what's the usual practice for writing posix signal handler in chicken?
See example program below. If you type something, it will simply echo it. You can type 'show' to print the a global flag. Ctrl-C will set the flag to true. If you hit ctrl-c rapidly, you'll send it into a loop consuming 100% cpu. (ctrl-\ to quit it) Am I correct that the signal handler written in scheme will be invoked asynchronously? How would one write this program in chicken correctly? Maybe there's a way to do an atomic operation to set the flag? Thanks, fungsin. (declare (uses extras regex posix utils srfi-13)) (require 'regex) (require 'posix) (require 'utils) (require-extension loop) (define *user-interrupted?* #f) (set-signal-handler! signal/int (lambda (signo) (set! *user-interrupted?* #t))) (loop for l = (read-line) while (and l (not (eof-object? l))) if (string= l "show") do (print *user-interrupted?*) else if (string= l "exit") do (exit 0) else do (write-line l)) _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users