X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fserial.c;h=f7746c41a866419171a091c593fd838600a71ca7;hb=464075aff16ebd285cd9c0bfe38e3706afcaeae4;hp=c0d2dbdae9fab589a295a44bd69b2f93b30f7a4f;hpb=b6b13e72e91d5b529a6306ce53bda685932c77db;p=mono.git diff --git a/support/serial.c b/support/serial.c index c0d2dbdae9f..f7746c41a86 100644 --- a/support/serial.c +++ b/support/serial.c @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -102,7 +103,9 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout) 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; @@ -322,7 +325,7 @@ set_signal (int fd, MonoSerialSignal signal, gboolean value) } gboolean -poll_serial (int fd, gint32 *error) +poll_serial (int fd, gint32 *error, int timeout) { struct pollfd pinfo; @@ -332,9 +335,12 @@ poll_serial (int fd, gint32 *error) 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;