|
From: <don...@is...> - 2010-09-28 20:16:57
|
Vladimir Tzankov writes: > When running within a signal handler you have very limited set of safe > functions to use (see at the end of > http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html). > No lisp code can be run safely from signal handler. > I see two ways to handle this: > > 1. With single thread builds: handle signals with signal handler, add > them to some queue of deferred (pending to be handled) signals and add > checkpoints in interpreter/bytecode to invoke handlers. For now let's start with case 2, which seems simpler, at least from my perspective. > 2. With MT: handle signals in main (non-lisp) thread via sigwait() and > use thread-interrupt to invoke handler in specific (or arbitrary) lisp > thread - that's the way CTRL-C and call-with-timeout are implemented. In this case I'd suggest creating a new thread to handle the signal. The general mechanism I had in mind was having a list of functions to call on each supported signal so the programmer can just push his own function onto that list. With-timeout presumably interrupts the calling thread. I suggest that if there are multiple running threads, c-c ask which one to interrupt. > Note that SIGUSR1 and SIGUSR2 are used internally for implementing > thread-interrupt and call-with-timeout - thus are not available. I gather there are several others that are used internally. > Besides SIGWINCH, what other signals would you like to be able to > handle? Some (SIGPIPE, SIGCLD) are already handled in special way by > the runtime. I don't know. I guess I should start by finding out which ones exist. |