[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a little puzzle
From: |
Andy Wingo |
Subject: |
a little puzzle |
Date: |
Fri, 08 Oct 2010 19:14:34 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Put this in your REPL and smoke it:
(define* (make-me-a-socket #:key
(host #f)
(addr (if host (inet-aton host) INADDR_LOOPBACK))
(port 37146))
(let ((server (socket PF_INET SOCK_STREAM 0)))
(setsockopt server SOL_SOCKET SO_REUSEADDR 1)
(bind server AF_INET addr port)
(listen server 5)
server))
(sigaction SIGINT (lambda (sig) (throw 'foo)))
(define s (make-me-a-socket))
(accept s) ; Now Ctrl-C
What do you expect to happen here?
Probably not this:
ERROR: In procedure accept:
ERROR: Interrupted system call
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]>
Throw to key `foo' with args `()' while reading expression.
scheme@(guile-user) [1]>
That's right: two throws for the price of one! The interrupted syscall,
and then the asynchronous signal. Fun...
Andy
--
http://wingolog.org/
- a little puzzle,
Andy Wingo <=