From c7b276f4e6c1fac896099dfddef1c6c69e132fb9 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sat, 3 Oct 2015 18:43:49 +0300 Subject: Use the qt_safe_select for waitForXX functions on *nix Now it is used the qt_safe_select() function similar to the Qt socket engine. Tested on Linux (kernel 4.1.7) with the USB and virtual tty0tty serial ports. Change-Id: Icd7a443ee5e0b5d6453a6e9973930f41e1313eeb Reviewed-by: Sergey Belyashov Reviewed-by: Denis Shienkov --- src/serialport/qserialport_unix.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index c243319..bced191 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -992,11 +992,11 @@ bool QSerialPortPrivate::waitForReadOrWrite(bool *selectForRead, bool *selectFor if (checkWrite) FD_SET(descriptor, &fdwrite); - struct timeval tv; + struct timespec tv; tv.tv_sec = msecs / 1000; - tv.tv_usec = (msecs % 1000) * 1000; + tv.tv_nsec = (msecs % 1000) * 1000 * 1000; - const int ret = ::select(descriptor + 1, &fdread, &fdwrite, 0, msecs < 0 ? 0 : &tv); + const int ret = qt_safe_select(descriptor + 1, &fdread, &fdwrite, 0, msecs < 0 ? 0 : &tv); if (ret < 0) { setError(getSystemError()); return false; -- cgit v1.2.1