1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

"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.
This commit is contained in:
Andy Wingo 2017-03-01 17:25:59 +01:00
parent 0660364998
commit 24eea1be08
2 changed files with 15 additions and 14 deletions

View file

@ -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
@code{select} 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.

View file

@ -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));