LINUX seems to interrupt writes & return a positive parial count
authorClaus Gittinger <cg@exept.de>
Thu, 11 Jan 1996 21:37:35 +0100
changeset 849 033900f9b217
parent 848 76a83f34c26a
child 850 6168719cb51b
LINUX seems to interrupt writes & return a positive parial count for ttys. Kludged around this ...
ExtStream.st
ExternalStream.st
--- a/ExtStream.st	Thu Jan 11 14:51:39 1996 +0100
+++ b/ExtStream.st	Thu Jan 11 21:37:35 1996 +0100
@@ -3317,6 +3317,30 @@
 		int cc, rest;
 
 		cnt = 0;
+#ifdef LINUX
+		rest = len;
+		do {
+                    /*
+                     * in linux, partial writes seem to be possible
+                     * with ttys when interrupted ...
+		     * I do not like this
+                     */
+		    do {
+		        cp = __ByteArrayInstPtr(aCollection)->ba_element + offs;
+                        cc = write(fileno(f), cp, rest);
+			if (cc > 0) {
+			    cnt += cc;
+			    offs += cc;
+			    rest -= cc;
+			} else {
+			    if (cc < 0) {
+				cnt = cc;
+			    }
+			}
+		    } while ((cc >= 0) && rest);
+		} while ((cnt < 0) && (errno == EINTR));
+
+#else
 		do {
 		    /*
 		     * refetch pointer in case of an interrupt
@@ -3324,6 +3348,7 @@
 		    cp = __ByteArrayInstPtr(aCollection)->ba_element + offs;
 		    cnt = write(fileno(f), cp, len);
 		} while ((cnt < 0) && (errno == EINTR));
+#endif
 	    } else {
 		__WRITING__(f)
 		cnt = fwrite(cp, 1, len, f);
@@ -3455,6 +3480,6 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.82 1996-01-03 23:25:58 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.83 1996-01-11 20:37:35 cg Exp $'
 ! !
 ExternalStream initialize!
--- a/ExternalStream.st	Thu Jan 11 14:51:39 1996 +0100
+++ b/ExternalStream.st	Thu Jan 11 21:37:35 1996 +0100
@@ -3317,6 +3317,30 @@
 		int cc, rest;
 
 		cnt = 0;
+#ifdef LINUX
+		rest = len;
+		do {
+                    /*
+                     * in linux, partial writes seem to be possible
+                     * with ttys when interrupted ...
+		     * I do not like this
+                     */
+		    do {
+		        cp = __ByteArrayInstPtr(aCollection)->ba_element + offs;
+                        cc = write(fileno(f), cp, rest);
+			if (cc > 0) {
+			    cnt += cc;
+			    offs += cc;
+			    rest -= cc;
+			} else {
+			    if (cc < 0) {
+				cnt = cc;
+			    }
+			}
+		    } while ((cc >= 0) && rest);
+		} while ((cnt < 0) && (errno == EINTR));
+
+#else
 		do {
 		    /*
 		     * refetch pointer in case of an interrupt
@@ -3324,6 +3348,7 @@
 		    cp = __ByteArrayInstPtr(aCollection)->ba_element + offs;
 		    cnt = write(fileno(f), cp, len);
 		} while ((cnt < 0) && (errno == EINTR));
+#endif
 	    } else {
 		__WRITING__(f)
 		cnt = fwrite(cp, 1, len, f);
@@ -3455,6 +3480,6 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.82 1996-01-03 23:25:58 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.83 1996-01-11 20:37:35 cg Exp $'
 ! !
 ExternalStream initialize!