Welcome to the CHICKEN Scheme pasting service
signal handling & load in C5 added by mario-goulart on Tue Aug 6 10:41:11 2019
$ cat hup.scm (cond-expand (chicken-4 (use posix)) (chicken-5 (import (chicken base) (chicken process signal) (chicken process-context)))) (define param (make-parameter 42)) (define conf-file (car (command-line-arguments))) ; (load conf-file) (set-signal-handler! signal/hup (lambda (signum) (print "reloading conf file") (load conf-file))) (let loop () (print (param)) (sleep 1) (loop)) $ cat conf.scm (param 4) ;;; Case 1: `(load conf-file)` in the toplevel commented out ;;; Steps: ;;; 1. run hup.scm ;;; 2. go to another terminal and kill it with signal 1 $ ~/local/chicken-4.13.0/bin/csi -s hup.scm conf.scm 42 42 42 reloading conf file 4 4 4 $ ~/local/chicken-5.1.0/bin/csi -s hup.scm conf.scm 42 42 42 reloading conf file 42 42 42 ;;; Case 2: `(load conf-file)` in the toplevel uncommented ;;; Steps: ;;; 1. run hup.scm ;;; 2. go to another terminal change param in conf.scm and kill csi ;;; with signal 1 $ ~/local/chicken-4.13.0/bin/csi -s hup.scm conf.scm 4 4 4 reloading conf file 10 10 10 $ ~/local/chicken-5.1.0/bin/csi -s hup.scm conf.scm 10 10 10 reloading conf file 12 12 12