(signal <sig> 'handler) doesn't work?

Started by ino-news, March 23, 2007, 11:00:27 AM

Previous topic - Next topic

ino-news

newLISP v.9.1.0 on FreeBSD



here's the code that doesn't work:



(define (sig-handler sig)

  (println %scriptname ": signal " sig)

  (cond

    ((member sig '(1 30 31))

     (save-iplist))

    (true

      (map (fn (_fd) (net-close (first _fd))) fds)

      (save-iplist)

      (exit sig))))

;; disables builtin handlers (ctrl-c?)

(command-line nil)

(dolist (s '(1 2 3 15 30 31) (signal s 'sig-handler)))



(save-iplist) would save some data in a file, this works. the program

runs "supervised", see http://smarden.org/runit/">http://smarden.org/runit/.  where the program

worked when using CTRL-C on the command line, it doesn't now.  i have

many daemons supervised, they all get their signals and invoke their

handlers, but newlisp doesn't.  the (println ...) text doesn't show up,

either.



what's wrong with my code?  --clemens
regards, clemens

Lutz

#1
There is a parenthesis missing in the last line after the list parameters. This shortened program works (hitting Ctrl-C) after loading:


~/Documents> uname -a
FreeBSD donlucio.net 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Mon Oct 27 17:51:09 GMT 2003     root@freebsd-stable.sentex.ca:/usr/obj/usr/src/sys/GENERIC  i386

~/Documents> ./sigtest
newLISP v.9.1.0 on BSD, execute 'newlisp -h' for more info.

> signal 2
saving
~/Documents> cat sigtest
#!/usr/bin/newlisp

(define (sig-handler sig)
        (println "signal " sig)
        (cond
                ((member sig '(1 30 31))
                        (println "SAVING"))
                (true
                        (println "saving")
                        (exit sig))))

;; disables builtin handlers (ctrl-c?)
(dolist (s '(1 2 3 15 30 31)) (signal s 'sig-handler))

~/Documents>


Lutz



ps: see also the file qa-setsig in the source distrubution, which can do a complete test of all signals

ino-news

#2
Quote from: "Lutz"There is a parenthesis missing in the last line after the

list parameters.


that was the correct answer!  wow, stupid one-liners!  thanks!



clemens
regards, clemens