{
int n;
-#ifdef HAVE_PPOLL
if (!blockp)
{
- n = (UX_poll (fds, nfds, 0));
+ if ((OS_process_any_status_change ()))
+ {
+ errno = EINTR;
+ n = -1;
+ }
+ else
+ {
+ n = (UX_poll (fds, nfds, 0));
+ }
}
else
+#ifdef HAVE_PPOLL
{
sigset_t old, new;
UX_sigfillset (&new);
UX_sigprocmask (SIG_SETMASK, &new, &old);
if ((OS_process_any_status_change ())
- || (pending_interrupts_p ()))
+ || ((GET_INT_CODE) != 0))
{
errno = EINTR;
n = -1;
UX_sigprocmask (SIG_SETMASK, &old, NULL);
}
#else /* not HAVE_PPOLL */
- /* There is a signal "hole" here, but what can we do without ppoll()? */
- INTERRUPTABLE_EXTENT
- (n, (((OS_process_any_status_change ())
- || (pending_interrupts_p ()))
- ? ((errno = EINTR), (-1))
- : (UX_poll (fds, nfds, (blockp ? INFTIM : 0)))));
+ {
+ INTERRUPTABLE_EXTENT
+ (n, (((OS_process_any_status_change ())
+ || ((GET_INT_CODE) != 0))
+ ? ((errno = EINTR), (-1))
+ : (UX_poll (fds, nfds, (blockp ? INFTIM : 0)))));
+ }
#endif
return (n);
int
OS_test_select_registry (select_registry_t registry, int blockp)
{
+ int nfds;
struct select_registry_s * r = registry;
- while (1)
- {
- int nfds = (safe_poll ((SR_ENTRIES (r)), (SR_N_FDS (r)), blockp));
- if (nfds >= 0)
- return (nfds);
- if (errno != EINTR)
- error_system_call (errno, syscall_select);
- if (OS_process_any_status_change ())
- return (SELECT_PROCESS_STATUS_CHANGE);
- if (pending_interrupts_p ())
- return (SELECT_INTERRUPT);
- }
+
+ nfds = (safe_poll ((SR_ENTRIES (r)), (SR_N_FDS (r)), blockp));
+ if (nfds >= 0)
+ return (nfds);
+ if (errno != EINTR)
+ error_system_call (errno, syscall_select);
+ if (OS_process_any_status_change ())
+ return (SELECT_PROCESS_STATUS_CHANGE);
+ return (SELECT_INTERRUPT);
}
int
OS_test_select_descriptor (int fd, int blockp, unsigned int mode)
{
+ int nfds;
struct pollfd pfds [1];
((pfds [0]) . fd) = fd;
((pfds [0]) . events) = (DECODE_MODE (mode));
- while (1)
- {
- int nfds = (safe_poll (pfds, 1, blockp));
- if (nfds > 0)
- return (ENCODE_MODE ((pfds [0]) . revents));
- if (nfds == 0)
- return (0);
- if (errno != EINTR)
- error_system_call (errno, syscall_select);
- if (OS_process_any_status_change ())
- return (SELECT_PROCESS_STATUS_CHANGE);
- if (pending_interrupts_p ())
- return (SELECT_INTERRUPT);
- }
+
+ nfds = (safe_poll (pfds, 1, blockp));
+ if (nfds > 0)
+ return (ENCODE_MODE ((pfds [0]) . revents));
+ if (nfds == 0)
+ return (0);
+ if (errno != EINTR)
+ error_system_call (errno, syscall_select);
+ if (OS_process_any_status_change ())
+ return (SELECT_PROCESS_STATUS_CHANGE);
+ return (SELECT_INTERRUPT);
}
#else /* not HAVE_POLL */
{
int n;
-#ifdef HAVE_PSELECT
if (!blockp)
{
- n = (UX_select (nfds, readfds, writefds, NULL, &zero_timeout));
+ if ((OS_process_any_status_change ()))
+ {
+ errno = EINTR;
+ n = -1;
+ }
+ else
+ {
+ n = (UX_select (nfds, readfds, writefds, NULL, &zero_timeout));
+ }
}
else
+#ifdef HAVE_PSELECT
{
sigset_t old, new;
UX_sigfillset (&new);
UX_sigprocmask (SIG_SETMASK, &new, &old);
if ((OS_process_any_status_change ())
- || (pending_interrupts_p ()))
+ || ((GET_INT_CODE) != 0))
{
errno = EINTR;
n = -1;
UX_sigprocmask (SIG_SETMASK, &old, NULL);
}
#else /* not HAVE_PSELECT */
- /* There is a signal "hole" here, but what can we do without pselect()? */
- INTERRUPTABLE_EXTENT
- (n, (((OS_process_any_status_change ())
- || (pending_interrupts_p ()))
- ? ((errno = EINTR), (-1))
- : (UX_select (nfds, readfds, writefds, NULL,
- (blockp ? NULL : &zero_timeout)))));
+ {
+ INTERRUPTABLE_EXTENT
+ (n, (((OS_process_any_status_change ())
+ || ((GET_INT_CODE) != 0))
+ ? ((errno = EINTR), (-1))
+ : (UX_select (nfds, readfds, writefds, NULL,
+ (blockp ? NULL : &zero_timeout)))));
+ }
#endif
return (n);
OS_test_select_registry (select_registry_t registry, int blockp)
{
#ifdef HAVE_SELECT
+ int nfds;
struct select_registry_s * r = registry;
(* (SR_RREADERS (r))) = (* (SR_QREADERS (r)));
(* (SR_RWRITERS (r))) = (* (SR_QWRITERS (r)));
- while (1)
- {
- int nfds = (safe_select (FD_SETSIZE,
- (SR_RREADERS (r)),
- (SR_RWRITERS (r)),
- blockp));
- if (nfds >= 0)
- return (nfds);
- if (errno != EINTR)
- error_system_call (errno, syscall_select);
- if (OS_process_any_status_change ())
- return (SELECT_PROCESS_STATUS_CHANGE);
- if (pending_interrupts_p ())
- return (SELECT_INTERRUPT);
- }
+ nfds = (safe_select (FD_SETSIZE,
+ (SR_RREADERS (r)),
+ (SR_RWRITERS (r)),
+ blockp));
+ if (nfds >= 0)
+ return (nfds);
+ if (errno != EINTR)
+ error_system_call (errno, syscall_select);
+ if (OS_process_any_status_change ())
+ return (SELECT_PROCESS_STATUS_CHANGE);
+ return (SELECT_INTERRUPT);
#else
error_system_call (ENOSYS, syscall_select);
return (1);
OS_test_select_descriptor (int fd, int blockp, unsigned int mode)
{
#ifdef HAVE_SELECT
+ int nfds;
SELECT_TYPE readable;
SELECT_TYPE writeable;
if ((mode & SELECT_MODE_WRITE) != 0)
FD_SET (fd, (&writeable));
- while (1)
- {
- int nfds = (safe_select (fd + 1, &readable, &writeable, blockp));
- if (nfds > 0)
- return
- (((FD_ISSET (fd, (&readable))) ? SELECT_MODE_READ : 0)
- | ((FD_ISSET (fd, (&writeable))) ? SELECT_MODE_WRITE : 0));
- if (nfds == 0)
- return (0);
- if (errno != EINTR)
- error_system_call (errno, syscall_select);
- if (OS_process_any_status_change ())
- return (SELECT_PROCESS_STATUS_CHANGE);
- if (pending_interrupts_p ())
- return (SELECT_INTERRUPT);
- }
+ nfds = (safe_select (fd + 1, &readable, &writeable, blockp));
+ if (nfds > 0)
+ return
+ (((FD_ISSET (fd, (&readable))) ? SELECT_MODE_READ : 0)
+ | ((FD_ISSET (fd, (&writeable))) ? SELECT_MODE_WRITE : 0));
+ if (nfds == 0)
+ return (0);
+ if (errno != EINTR)
+ error_system_call (errno, syscall_select);
+ if (OS_process_any_status_change ())
+ return (SELECT_PROCESS_STATUS_CHANGE);
+ return (SELECT_INTERRUPT);
#else
error_system_call (ENOSYS, syscall_select);
return (1);
UX_sigprocmask (SIG_SETMASK, &new, &old);
if (OS_process_any_status_change ())
n = SELECT_PROCESS_STATUS_CHANGE;
- else if (pending_interrupts_p ())
+ else if ((GET_INT_CODE) != 0)
n = SELECT_INTERRUPT;
else
{
#else /* not HAVE_SIGSUSPEND */
INTERRUPTABLE_EXTENT
(n, (((OS_process_any_status_change ())
- || (pending_interrupts_p ()))
+ || ((GET_INT_CODE) != 0))
? ((errno = EINTR), (-1))
: ((UX_pause ()), (0))));
if (OS_process_any_status_change())