2008-03-31 Miguel de Icaza <miguel@novell.com>
[mono.git] / support / serial.c
index 9443e0bb92301756c8d80c3db36ed31dafcec662..4775805aaf5950ddcb38db917c617e4a26722c80 100644 (file)
@@ -95,7 +95,7 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout)
        fd_set writefs;
        guint32 n;
 
-       n = count - offset;
+       n = count;
 
        FD_SET(fd, &writefs);
        tmval.tv_sec = timeout / 1000;
@@ -113,7 +113,12 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout)
                        }
                }               
 
-               t = write(fd, buffer + offset, count);
+               do {
+                       t = write (fd, buffer + offset, n);
+               } while (t == -1 && errno == EINTR);
+
+               if (t < 0)
+                       return -1;
                
                if (timeout > 0)
                {
@@ -121,7 +126,7 @@ write_serial (int fd, guchar *buffer, int offset, int count, int timeout)
                        {
                                return -1;
                        }
-       }
+               }
 
                offset += t;
                n -= t;