guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 03/03: "select" no longer throws exception on EINTR


From: Andy Wingo
Subject: [Guile-commits] 03/03: "select" no longer throws exception on EINTR
Date: Wed, 1 Mar 2017 11:28:17 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit 24eea1be08391475fe932f44df51ebe1aca75a2b
Author: Andy Wingo <address@hidden>
Date:   Wed Mar 1 17:25:59 2017 +0100

    "select" no longer throws exception on EINTR
    
    * doc/ref/posix.texi (Ports and File Descriptors): Update.
    * libguile/filesys.c (scm_select): Use scm_std_select so that pending
      interrupts can be delivered.  On EINTR or EAGAIN, just return directly
      so that calling Scheme code can run asyncs.
---
 doc/ref/posix.texi |  8 ++++----
 libguile/filesys.c | 21 +++++++++++----------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 4afe6bf..6f9ce54 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -529,10 +529,10 @@ to provide input, accept output, or the existence of
 exceptional conditions on a collection of ports or file
 descriptors, or waiting for a timeout to occur.
 
-When an error occurs, of if it is interrupted by a signal, this
-procedure throws a @code{system-error} exception
-(@pxref{Conventions, @code{system-error}}).  In case of an
-interruption, the associated error number is @var{EINTR}.
+When an error occurs, this procedure throws a @code{system-error}
+exception (@pxref{Conventions, @code{system-error}}).  Note that
address@hidden may return early for other reasons, for example due to
+pending interrupts.  @xref{Asyncs}, for more on interrupts.
 
 @var{reads}, @var{writes} and @var{excepts} can be lists or
 vectors, with each member a port or a file descriptor.
diff --git a/libguile/filesys.c b/libguile/filesys.c
index b5b7e72..478369d 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -44,6 +44,7 @@
 #include "libguile/feature.h"
 #include "libguile/fports.h"
 #include "libguile/strings.h"
+#include "libguile/iselect.h"
 #include "libguile/vectors.h"
 #include "libguile/dynwind.h"
 #include "libguile/ports.h"
@@ -79,8 +80,6 @@
 #include <libc.h>
 #endif
 
-#include <sys/select.h>
-
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
@@ -776,10 +775,9 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
            "exceptional conditions on a collection of ports or file\n"
            "descriptors, or waiting for a timeout to occur.\n\n"
 
-           "When an error occurs, of if it is interrupted by a signal, this\n"
-           "procedure throws a @code{system-error} exception\n"
-           "(@pxref{Conventions, @code{system-error}}).  In case of an\n"
-           "interruption, the associated error number is @var{EINTR}.\n\n"
+           "When an error occurs, this procedure throws a\n"
+            "@code{system-error} exception "
+            "(@pxref{Conventions, @code{system-error}}).\n\n"
 
            "@var{reads}, @var{writes} and @var{excepts} can be lists or\n"
            "vectors, with each member a port or a file descriptor.\n"
@@ -899,12 +897,15 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
     }
 
   {
-    int rv = select (max_fd + 1,
-                     &read_set, &write_set, &except_set,
-                     time_ptr);
-    if (rv < 0)
+    int rv = scm_std_select (max_fd + 1,
+                             &read_set, &write_set, &except_set,
+                             time_ptr);
+    /* Let EINTR / EAGAIN cause a return to the user and let them loop
+       to run any asyncs that might be pending.  */
+    if (rv < 0 && errno != EINTR && errno != EAGAIN)
       SCM_SYSERROR;
   }
+
   return scm_list_3 (retrieve_select_type (&read_set, read_ports_ready, reads),
                     retrieve_select_type (&write_set, write_ports_ready, 
writes),
                     retrieve_select_type (&except_set, SCM_EOL, excepts));



reply via email to

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