[racket] SIgnal-catching in Racket
Hi all,
If I wanted to catch a Unix signal (say, SIGUSR1) within my Racket
program, how should I go about it?
My current best guess is:
- load a C extension, which
- creates a semaphore and
- hooks the signal with a handler (MZ_SIGSET looks relevant), which
- posts to the semaphore when the signal arrives.
However this seems like a recipe for problems. Is it even permitted to
post to a semaphore from a signal handler? Will the runtime be upset
about unscheduled intrusions into its demesne? Is it possible for a C
extension to allocate a global value like a semaphore and make it
available to Racket code?
Is there a better way?
- Perhaps a self-pipe would be better than a semaphore?
- A thread from 2006 [1] points at scheme_signal_received() but
I don't understand why creating an event type is the right thing
to do.
Tony
[1] http://lists.racket-lang.org/users/archive/2006-July/013999.html