guicho271828/trivial-signal

invoke-handlers error on CCL/linux

Closed this issue · 2 comments

ralt commented

A simple file like this:

(ql:quickload :trivial-signal)

(trivial-signal:signal-handler-bind ((2 (lambda (c)
					  (format t "hi!~%"))))
  (sleep 99))

If you try to Ctrl-c during the sleep, it throws this error:

^C-------- handler invoked in thread: listener -------
hierarchy: (((2 #<Anonymous Function #x30200161994F>)))hi!
> Error: received INT
>        
> While executing: TRIVIAL-SIGNAL::INVOKE-HANDLERS, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Skip evaluation of (ros:run '((:eval"(ros:quicklisp)")(:script "../test.lisp")(:quit ())))
> Type :? for other options.

By replacing 2 with "foo", I saw an interesting error at compile-time:

> Error: The value "foo" is not of the expected type SYMBOL.

So ccl apparently expects signo to be a symbol, not a number.

That said, it throws the same error when I tried using 'foo:

> Error: The value 'FOO is not of the expected type SYMBOL.

So I'm not sure what it's expecting.

So, three questions...

  1. Why it throws an error, although I handled the signal? -> The behavior of signal-handler-bind is analogous to handler-bind. Therefore your code did not handle the signal, you declined the signal. To see this difference, please refer to the definition of handle and decline: You printed "hi" and returned from the lambda without a local exit, so you declined the signal. To handle the signal, you have to jump outside the handler via non-local exit such as tagbody+go or block+return-from or throw+catch combo.
  2. The valid designator for signals are defined here: It should be a keyword or a number.
  3. This case is interesting, what you saw is actually 'FOO not FOO, which means it is a cons (quote foo) that happened to be pretty-printed. This is confusing for the users and I believe it is a bug.
ralt commented

Thanks for the explanation! I was indeed missing things :)