Fix a small mistake in recalculating the timeout in case we get interrupted twice by a signal.
Fix a small mistake in recalculating the timeout in case we get
interrupted twice by a signal.

If we're interrupted only once, there's no problem. If we're
interrupted twice, we subtract the elapsed time since the beginning
from the remaining time, so this won't work. The correct thing is to
recalculate from the original timeout value.

This is extremely difficult to test, since it requires that the
select(2) call be interrupted twice by signals. The only way to do
this is by sending two signals to a program from another program (or
threads, with pthread_kill(3)) with less than half of the time left,
then send data to cause the loop to exit with success.

Reviewed-by: Peter Hartmann <6d46a110f770389fd96d98f36cd2fce6c18ea536@nokia.com>

igor-sfdc/qt-wk,pruiz/wkhtmltopdf-qt,RLovelett/qt,pruiz/wkhtmltopdf-qt,pruiz/wkhtmltopdf-qt,pruiz/wkhtmltopdf-qt,radekp/qt,pruiz/wkhtmltopdf-qt,radekp/qt,pruiz/wkhtmltopdf-qt,pruiz/wkhtmltopdf-qt,igor-sfdc/qt-wk,igor-sfdc/qt-wk,KDE/qt,RLovelett/qt,RLovelett/qt,radekp/qt,igor-sfdc/qt-wk,RLovelett/qt,KDE/qt,igor-sfdc/qt-wk,KDE/qt,RLovelett/qt,RLovelett/qt,pruiz/wkhtmltopdf-qt,radekp/qt,RLovelett/qt,KDE/qt,pruiz/wkhtmltopdf-qt,KDE/qt,KDE/qt,radekp/qt,igor-sfdc/qt-wk,radekp/qt,RLovelett/qt,RLovelett/qt,igor-sfdc/qt-wk,RLovelett/qt,radekp/qt,igor-sfdc/qt-wk,radekp/qt,pruiz/wkhtmltopdf-qt,pruiz/wkhtmltopdf-qt,igor-sfdc/qt-wk,radekp/qt,radekp/qt,KDE/qt,igor-sfdc/qt-wk,igor-sfdc/qt-wk,RLovelett/qt,KDE/qt