Hello, This lets select get interrupted by signals: without passing MACH_RCV_INTERRUPT to __mach_msg, it would just loop again on signal delivery. Worse, the timeout would be reused as such (as documented for mach_msg), leading to potential infinite loop when getting frequent-enough signals.
This patch syntaxically depends on my previous one, but it's actually independent. The important point is just that the handling code is before the test for if(got), so that getting interrupted after having gotten some answers will keep err set to 0. Samuel hurdselect: let select get interrupted by signals * hurd/hurdselect.c (_hurd_select): Pass MACH_RCV_INTERRUPT to __mach_msg. If that returns MACH_RCV_INTERRUPTED, set ERR to EINTR. diff --git a/hurd/hurdselect.c b/hurd/hurdselect.c index 974c3c3..fae21a2 100644 --- a/hurd/hurdselect.c +++ b/hurd/hurdselect.c @@ -335,7 +335,7 @@ _hurd_select (int nfds, mach_msg_option_t options = (timeout == NULL ? 0 : MACH_RCV_TIMEOUT); error_t msgerr; while ((msgerr = __mach_msg (&msg.head, - MACH_RCV_MSG | options, + MACH_RCV_MSG | MACH_RCV_INTERRUPT | options, 0, sizeof msg, portset, to, MACH_PORT_NULL)) == MACH_MSG_SUCCESS) { @@ -407,6 +407,10 @@ _hurd_select (int nfds, } } + if (msgerr == MACH_RCV_INTERRUPTED) + /* Interruption on our side (e.g. signal reception). */ + err = EINTR; + if (got) /* At least one descriptor is known to be ready now, so we will return success. */