Make a copy of the provided timeout before calling select(2).

This commit is contained in:
Romain Tartiere 2011-09-29 15:01:48 +00:00
parent 8f7834c625
commit 311d12feef

View file

@ -267,6 +267,16 @@ select:
FD_SET (iAbortFd, &rfds);
}
/*
* Some implementations (e.g. Linux) of select(2) will update *timeout.
* Make a copy so that it will be updated on these systems,
*/
struct timeval fixed_timeout;
if (timeout) {
fixed_timeout = *timeout;
timeout = &fixed_timeout;
}
res = select (MAX(((serial_port_unix *) sp)->fd, iAbortFd) + 1, &rfds, NULL, NULL, timeout);
if ((res < 0) && (EINTR == errno)) {