guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A timely question on interrupted system calls


From: Ludovic Courtès
Subject: Re: A timely question on interrupted system calls
Date: Thu, 11 Jul 2013 14:07:31 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

address@hidden 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’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]