aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.h.in4
-rw-r--r--src/main.c18
2 files changed, 22 insertions, 0 deletions
diff --git a/src/config.h.in b/src/config.h.in
index 6ebc04c8a..fdd8f65f7 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -31,3 +31,7 @@
/* Define if you have the `setvbuf' function. */
#undef HAVE_SETVBUF
+
+/* Define if you have the `poll' function. */
+#undef HAVE_POLL
+
diff --git a/src/main.c b/src/main.c
index 998b1f3e4..a7533a00f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1878,8 +1878,26 @@ static int parseconfig(const char *filename,
static void go_sleep(long ms)
{
+#ifdef HAVE_POLL
/* portable subsecond "sleep" */
poll((void *)0, 0, ms);
+#else
+ /* systems without poll() need other solutions */
+
+#ifdef WIN32
+ /* Windows offers a millisecond sleep */
+ Sleep(ms);
+#else
+ /* Other systems must use select() for this */
+ struct timeval timeout;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = ms * 1000;
+
+ select(0, NULL, NULL, NULL, &timeout);
+#endif
+
+#endif
}
struct OutStruct {