From: ludo@gnu.org (Ludovic Courtès)
To: guile-user@gnu.org
Subject: Re: A timely question on interrupted system calls
Date: Thu, 11 Jul 2013 14:07:31 +0200 [thread overview]
Message-ID: <87ppupe1vg.fsf@gnu.org> (raw)
In-Reply-To: 87zjttk32l.fsf@mark-desktop.PK5001Z
mark.d.witmer@gmail.com skribis:
> I followed the thread a few days ago on @guile-dev about SCM_SYSCALL and
> was grateful I hadn't run into any problems with it. But now I have!
Excellent. :-)
> I'm working with an event loop for my X bindings that polls a socket for
> availablity using `select'. Meanwhile, I have a repl server running in
> another thread. When something connects to the server, the call to
> `select' get interrupted and throws a system error. In the following
> code the catch expression doesn't catch the system error:
Could it be that it’s actually the other thread that gets EINTR?
> (define (file-ready? fd)
> (memq fd
> (car
> (catch 'system-error
> (lambda () (select (list fd) '() '() 0 16667))
> (lambda args
> (if (= (system-error-errno args) EINTR)
> '(() () ()) ;; Assume it isn't available for now
> (apply throw args)))))))
>
> I gathered from what I read that the error is getting handled in a
> system async, which could explain why my catch expression doesn't see
> it.
No: single handlers are run from an async, but the ‘system-error’ for
EINTR it thrown immediately.
> I also tried a couple versions of `sigaction' without any luck:
>
> (sigaction SIGINT (lambda (signum) #t) SA_RESTART)
>
> and
>
> (sigaction SIGINT #f SA_RESTART)
You mean you still get EINTR with that?
In my experience SA_RESTART works as advertised, with the caveat that
execution of system asyncs (such as signal handlers) are delayed until
the syscall completes (see <http://bugs.gnu.org/14640>.)
Thanks,
Ludo’.
next prev parent reply other threads:[~2013-07-11 12:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-11 6:45 A timely question on interrupted system calls mark.d.witmer
2013-07-11 12:07 ` Ludovic Courtès [this message]
2013-07-12 4:26 ` mark.d.witmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ppupe1vg.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).