[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] #1638: Signal handling and parameters
From: |
Chicken Trac |
Subject: |
[Chicken-janitors] #1638: Signal handling and parameters |
Date: |
Tue, 06 Aug 2019 10:30:04 -0000 |
#1638: Signal handling and parameters
---------------------------------------+--------------------------------
Reporter: mario | Owner:
Type: defect | Status: new
Priority: major | Milestone: someday
Component: unknown | Version: 5.1.0
Keywords: signals, parameters, load | Estimated difficulty:
---------------------------------------+--------------------------------
I'm facing a difference in behavior between C4 and C5 regarding signal
handling, parameters and load.
The code below hopefully helps illustrate the problem.
There's a loop printing the value of a parameter, and a signal handler
that catches SIGHUP and loads a file which sets the parameter.
Case 1: In C4, when the process catches SIGHUP and loads the configuration
file, the value of the parameter changes. In C5, the value doesn't
change.
Case 2: if we call {{{(load conf-file)}}} in the toplevel, both C4 and C5
behave the same (expected behavior).
The problem seems to be related to parameters. I tried this code with a
regular variable instead of a parameter (using {{{set!}}} to set it), and
in that scenario the program behaves as expected.
{{{
$ 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.
;;; Notice that now the conf file is loaded in the toplevel and
;;; the configuration file contains `(param 4)'.
;;; Steps:
;;; 1. run hup.scm
;;; 2. go to another terminal change param in conf.scm (to 10)
;;; 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
;;; Here the config file has the param set to 10 (previous execution)
;;; and I set it to 12 before sending signal 1 to csi.
$ ~/local/chicken-5.1.0/bin/csi -s hup.scm conf.scm
10
10
10
reloading conf file
12
12
12
}}}
--
Ticket URL: <https://bugs.call-cc.org/ticket/1638>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.
- [Chicken-janitors] #1638: Signal handling and parameters,
Chicken Trac <=