Fix select() on Linux

This fixes a bug where the caller's timeval will be clobbered on Linux.
The Kernel ABI *always* modifies the timeout argument but POSIX says it
should be a const parameter. The wrapper now handles the difference and
sys_select() may be used if obtaining the remainder on Linux is needed.
This commit is contained in:
Justine Tunney 2023-02-23 06:03:06 -08:00
parent dfabcd84c1
commit 0f1ead8943
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 17 additions and 6 deletions

View file

@ -212,7 +212,7 @@ static bool ShouldUseSpinNanosleep(int clock, int flags,
* while (clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &abs, 0));
*
* will accurately spin on `EINTR` errors. That way you're not impeding
* signal delivery and you're not losing precision on your wait timeout.
* signal delivery and you're not loosing precision on the wait timeout.
* This function has first-class support on Linux, FreeBSD, and NetBSD;
* on OpenBSD it's good; on XNU it's bad; and on Windows it's ugly.
*