Include example in scribblings

This commit is contained in:
Tony Garnock-Jones 2016-09-13 18:27:32 -04:00
parent ed90022d80
commit 423f8617d2
1 changed files with 10 additions and 0 deletions

View File

@ -49,6 +49,16 @@ use @racket[next-signal-evt] or @racket[read-signal]. Use
signal (@tt{SIG_IGN}) or to install the default
signal-handler (@tt{SIG_DFL}), respectively.
@racketblock[
(require unix-signals)
(capture-signal! 'SIGUSR1)
(capture-signal! 'SIGUSR2)
(printf "Try 'kill -USR1 ~a' and 'kill -USR2 ~a'\n" (getpid) (getpid))
(let loop ()
(define signum (read-signal))
(printf "Received signal ~v (name ~v)\n" signum (lookup-signal-name signum))
(loop))]
Calls to @racket[capture-signal!] and friends have @emph{global} effect
within the Racket process. Likewise, use of @racket[next-signal-evt]
and @racket[read-signal] have global side-effects on the state of the