diff options
author | Andy Wingo <wingo@pobox.com> | 2017-03-01 17:25:59 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2017-03-01 17:27:56 +0100 |
commit | 24eea1be08391475fe932f44df51ebe1aca75a2b (patch) | |
tree | 22d69f74cc401af1d399a944d7e5dff7451830ba /libguile | |
parent | 0660364998a5d6492858cd7270e7e7349521711d (diff) |
"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.
Diffstat (limited to 'libguile')
-rw-r--r-- | libguile/filesys.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c index b5b7e723b..478369df0 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)); |