From 0376026d3127c64497290d0ed78666133ff27b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 1 Feb 2021 18:49:31 +0100 Subject: [PATCH] Time: handle EINTR on select() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8a1adc31541d2174d27729cfcd1bcb26e5d3e4fa Reviewed-on: https://review.haiku-os.org/c/haiku/+/3728 Reviewed-by: waddlesplash Reviewed-by: Axel Dörfler --- src/preferences/time/ntp.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/preferences/time/ntp.cpp b/src/preferences/time/ntp.cpp index d07b402e8b..91668ce5df 100644 --- a/src/preferences/time/ntp.cpp +++ b/src/preferences/time/ntp.cpp @@ -172,7 +172,12 @@ ntp_update_time(const char* hostname, const char** errorString, timeout.tv_usec = 0; // we'll wait 3 seconds for the answer - if (select(connection + 1, &waitForReceived, NULL, NULL, &timeout) <= 0) { + int status; + do { + status = select(connection + 1, &waitForReceived, NULL, NULL, + &timeout); + } while (status == -1 && errno == EINTR); + if (status <= 0) { *errorString = B_TRANSLATE("Waiting for answer failed"); *errorCode = errno; close(connection);