--- a/ExtStream.st Fri Mar 31 04:52:25 1995 +0200
+++ b/ExtStream.st Sun Apr 02 13:07:58 1995 +0200
@@ -24,7 +24,7 @@
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.32 1995-03-18 05:04:04 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.33 1995-04-02 11:06:23 claus Exp $
'!
!ExternalStream primitiveDefinitions!
@@ -87,7 +87,7 @@
version
"
-$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.32 1995-03-18 05:04:04 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.33 1995-04-02 11:06:23 claus Exp $
"
!
@@ -163,10 +163,22 @@
has big problems handling unbounded Streams, since the EOF handling in stdio is
not prepared for data to arrive after EOF has been reached - time will show, if we need
a complete rewrite for UnboundedStream ...
+
Also, depending on the system, the stdio library behaves infriendly when signals
occur while reading (for example, timer interrupts) - on real unixes (i.e. BSD) the signal
is handled transparently - on SYS5.3 (i.e. non unixes :-) the read operation returns
an error and errno is set to EINTR. Thats what the ugly code around all getc-calls is for.
+
+ Notice that typical stdio's use a single errno global variable to return an error code,
+ this was bad design in the stdio lib (right from the very beginning), since its much
+ harder to deal with this in the presence of lightweight processes, where errno gets
+ overwritten by an I/O operation done in another thread. (stdio should have been written
+ to return errno as a negative number ...).
+ To deal with this, the scheduler treats errno like a per-thread private variable,
+ and saves/restores the errno setting when switching to another thread.
+ (Notice that some thread packages do this also, but ST/X's thread implementation
+ does not depend on those, but instead uses a portable private package).
+
Finally, if an stdio-stream is open for both reading and writing, we have to call
fseek whenever we are about to read after write and vice versa.
Two macros (__READING__ and __WRITING__) have been defined to be used before every
@@ -2390,7 +2402,7 @@
__immediateInterrupt__ = 1;
do {
c = getc(f);
- } while ((c < 0) && (errno == EINTR));
+ } while ((c < 0) && (errno == EINTR) && (clearerr(f), 1));
__immediateInterrupt__ = 0;
if (c != EOF) {