[racket] SIgnal-catching in Racket

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat Dec 20 14:12:06 EST 2014

I don't know myself, but control-c raises an exception from an
OS-level signal handler and so probably you'll have to make a similar
bridge and that code might be worth looking at.


On Sat, Dec 20, 2014 at 1:05 PM, Tony Garnock-Jones <tonyg at ccs.neu.edu> wrote:
> 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
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.