#BUGFIX by stefan
class: ExternalStream
changed:
#canReadWithoutBlocking (send #fileHandle instead of #fileDescriptor)
#canWriteWithoutBlocking (send #fileHandle instead of #fileDescriptor)
#fileDescriptor
#numAvailableForRead (send #fileHandle instead of #fileDescriptor)
#readWaitWithTimeoutMs: (send #fileHandle instead of #fileDescriptor)
#readWriteWaitWithTimeoutMs: (send #fileHandle instead of #fileDescriptor)
#writeExceptionWaitWithTimeoutMs: (send #fileHandle instead of #fileDescriptor)
#writeWaitWithTimeoutMs: (send #fileHandle instead of #fileDescriptor)
fix for selecting on Stdin, Stdout, Stderr
https://expeccoalm.exept.de/D172525
--- a/ExternalStream.st Thu Jan 12 18:56:44 2017 +0100
+++ b/ExternalStream.st Thu Jan 12 19:02:13 2017 +0100
@@ -2119,14 +2119,15 @@
OBJ _handle = __INST(handle);
if (_handle != nil) {
- if (__INST(handleType) == @symbol(socketHandle)) {
- RETURN (_handle);
- } else if ((__INST(handleType) == nil)
- || (__INST(handleType) == @symbol(filePointer))
- || (__INST(handleType) == @symbol(socketFilePointer))
- || (__INST(handleType) == @symbol(pipeFilePointer))) {
- RETURN ( __MKINT(fileno(__FILEVal(_handle))));
- }
+ if ((__INST(handleType) == @symbol(fileHandle))
+ || (__INST(handleType) == @symbol(socketHandle))) {
+ RETURN (_handle);
+ } else if ((__INST(handleType) == nil)
+ || (__INST(handleType) == @symbol(filePointer))
+ || (__INST(handleType) == @symbol(socketFilePointer))
+ || (__INST(handleType) == @symbol(pipeFilePointer))) {
+ RETURN ( __MKINT(fileno(__FILEVal(_handle))));
+ }
}
%}.
handle isNil ifTrue:[^ self errorNotOpen].
@@ -5620,18 +5621,18 @@
We know, that error conditions do not block, so return true for errors."
^ readAhead notNil
- or:[handle isNil
- or:[mode == #writeonly
- or:[OperatingSystem readCheck:self fileDescriptor]]]
+ or:[handle isNil
+ or:[mode == #writeonly
+ or:[OperatingSystem readCheck:self fileHandle]]]
"
|pipe|
pipe := PipeStream readingFrom:'(sleep 10; echo hello)'.
pipe canReadWithoutBlocking ifTrue:[
- Transcript showCR:'data available'
+ Transcript showCR:'data available'
] ifFalse:[
- Transcript showCR:'no data available'
+ Transcript showCR:'no data available'
].
pipe close
"
@@ -5645,8 +5646,8 @@
We know, that error conditions do not block, so return true for errors."
^ handle isNil
- or:[mode == #readonly
- or:[OperatingSystem writeCheck:self fileDescriptor]]
+ or:[mode == #readonly
+ or:[OperatingSystem writeCheck:self fileHandle]]
!
gotErrorOrEOF
@@ -5713,7 +5714,7 @@
mode == #writeonly ifTrue:[
^ self errorWriteOnly
].
- available := OperatingSystem numAvailableForReadOn:self fileDescriptor.
+ available := OperatingSystem numAvailableForReadOn:self fileHandle.
readAhead notNil ifTrue:[
available := available + 1
].
@@ -5738,7 +5739,7 @@
handle isNil ifTrue:[^ self errorNotOpen].
mode == #writeonly ifTrue:[^ self errorWriteOnly].
- fd := self fileDescriptor.
+ fd := self fileHandle.
(OperatingSystem readCheck:fd) ifTrue:[^ false].
"cannot do a readWait (which means possible suspend),
@@ -5784,7 +5785,7 @@
^ self errorNotOpen
].
- fd := self fileDescriptor.
+ fd := self fileHandle.
(OperatingSystem readWriteCheck:fd) ifTrue:[^ false].
wasBlocked := OperatingSystem blockInterrupts.
@@ -5822,7 +5823,7 @@
^ self errorNotOpen
].
- fd := self fileDescriptor.
+ fd := self fileHandle.
(OperatingSystem writeExceptionCheck:fd) ifTrue:[^ false].
wasBlocked := OperatingSystem blockInterrupts.
@@ -5863,7 +5864,7 @@
^ self errorReadOnly
].
- fd := self fileDescriptor.
+ fd := self fileHandle.
(OperatingSystem writeCheck:fd) ifTrue:[^ false].
wasBlocked := OperatingSystem blockInterrupts.