#include <string.h>
#include <sys/poll.h>
#include <sys/ioctl.h>
+#include <errno.h>
#include <glib.h>
ufd.fd = fd;
ufd.events = POLLHUP | POLLOUT | POLLERR;
- poll (&ufd, 1, timeout);
+ while (poll (&ufd, 1, timeout) == -1 && errno == EINTR){
+
+ }
if ((ufd.revents & POLLOUT) != POLLOUT) {
return;
}
gboolean
-poll_serial (int fd, gint32 *error)
+poll_serial (int fd, gint32 *error, int timeout)
{
struct pollfd pinfo;
pinfo.events = POLLIN;
pinfo.revents = 0;
- if (poll (&pinfo, 1, 0) == -1) {
- *error = -1;
- return FALSE;
+ while (poll (&pinfo, 1, timeout) == -1 && errno == EINTR) {
+ /* EINTR is an OK condition, we should not throw in the upper layer an IOException */
+ if (errno != EINTR){
+ *error = -1;
+ return FALSE;
+ }
}
return (pinfo.revents & POLLIN) != 0 ? 1 : 0;