- if(!mainloop_unhandled_signals())
- ret=select(nfds+1, &rfds, NULL, NULL, tv);
+ bool to=libmainloop_get_timeout(&tv);
+
+ if(mainloop_unhandled_signals()){
+ ret=0;
+ break;
+ }
+
+ ret=select(nfds+1, &rfds, NULL, NULL, to ? &tv : NULL);
+ }while(ret<0 && errno==EINTR && !mainloop_unhandled_signals());