aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-05-11 10:42:26 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-05-11 10:42:26 +0000
commit648b2e9209d5da04aff5f8a24aed1cd03a110f8d (patch)
tree9f7821fc8a06e4dfec705d79fd8e9a4f4f755103
parentc5d6bea6d9f98a593890f9694ef1575d744e5a32 (diff)
downloadskalibs-648b2e9209d5da04aff5f8a24aed1cd03a110f8d.tar.gz
Rename sysdep to selectinfinite, find correct test value for timeout
-rwxr-xr-xconfigure4
-rw-r--r--src/libstddjb/iopause_select.c4
-rw-r--r--src/sysdeps/tryselectinfinite.c (renamed from src/sysdeps/tryselectshorttimeout.c)11
3 files changed, 10 insertions, 9 deletions
diff --git a/configure b/configure
index 7105869..8a274f6 100755
--- a/configure
+++ b/configure
@@ -55,7 +55,7 @@ List of mandatory sysdeps to provide by hand for cross-compiling:
devurandom (yes|no): =yes if the target has a working /dev/urandom
posixspawnearlyreturn (yes|no): =yes if the target has an old glibc or otherwise bad posix_spawn
procselfexe (path|none): =path if you can get the executable name via readlink(path)
- selectshorttimeout (yes|no): =yes if the target's select() fails on very long timeouts (MacOS, old OpenBSD)
+ selectinfinite (yes|no): =no if the target's select() fails on long timeouts (MacOS, old OpenBSD)
EOF
exit 0
}
@@ -734,7 +734,7 @@ choose cl pthreadmutexclocklock 'pthread_mutex_clocklock()' $pthread_lib
choose clr devurandom '/dev/urandom'
choose clr posixspawnearlyreturn 'posix_spawn() return early' $spawn_lib
choosevalue procselfexe '/proc/self/exe' /proc/self/exe /proc/curproc/exe /proc/curproc/file /proc/self/path/a.out
-choose clr selectshorttimeout 'a select() that fails on long timeouts'
+choose clr selectinfinite 'a select() that supports very long timeouts'
# Finally, produce config.mak and config.h
diff --git a/src/libstddjb/iopause_select.c b/src/libstddjb/iopause_select.c
index 863bea7..45ce19e 100644
--- a/src/libstddjb/iopause_select.c
+++ b/src/libstddjb/iopause_select.c
@@ -30,10 +30,10 @@ int iopause_select (iopause_fd *x, unsigned int len, tain const *deadline, tain
if (errno != EOVERFLOW) return -1 ;
else deadline = 0 ;
}
-#ifdef SKALIBS_HASSELECTSHORTTIMEOUT
+#ifndef SKALIBS_HASSELECTINFINITE
if (deadline && tv.tv_sec >= 100000000)
{
- tv.tv_sec = 99999999 ;
+ tv.tv_sec = 100000000 ;
tv.tv_usec = 0 ;
}
#endif
diff --git a/src/sysdeps/tryselectshorttimeout.c b/src/sysdeps/tryselectinfinite.c
index 9049079..83b2c06 100644
--- a/src/sysdeps/tryselectshorttimeout.c
+++ b/src/sysdeps/tryselectinfinite.c
@@ -17,18 +17,19 @@
#include <sys/time.h>
#include <sys/select.h>
#include <unistd.h>
+#include <errno.h>
#include <signal.h>
static void alrm_handler (int sig)
{
(void)sig ;
- _exit(1) ;
+ _exit(0) ;
}
int main (void)
{
- struct sigaction action = { .sa_handler = &alrm_handler, .sa_flags = SA_NOCLDSTOP | SA_RESTART } ;
- struct timeval tv = { .tv_sec = 100000000, .tv_usec = 0 } ;
+ struct sigaction action = { .sa_handler = &alrm_handler, .sa_flags = SA_NOCLDSTOP } ;
+ struct timeval tv = { .tv_sec = 100000001, .tv_usec = 0 } ;
fd_set r, w, x ;
FD_ZERO(&r) ;
FD_ZERO(&w) ;
@@ -36,6 +37,6 @@ int main (void)
sigfillset(&action.sa_mask) ;
if (sigaction(SIGALRM, &action, 0) == -1) _exit(111) ;
alarm(1) ;
- if (select(1, &r, &w, &x, &tv) == -1) _exit(errno == EINVAL ? 0 : 111) ;
- _exit(1) ;
+ select(1, &r, &w, &x, &tv) ;
+ _exit(errno == EINVAL ? 1 : 111) ;
}