PipeStream.st
changeset 21228 7c2104239a0f
parent 21211 ed5fd0f7a98b
child 21231 985ae4f2c424
--- a/PipeStream.st	Wed Jan 11 22:40:32 2017 +0100
+++ b/PipeStream.st	Thu Jan 12 00:17:39 2017 +0100
@@ -525,12 +525,12 @@
     "terminate first under windows"
     OperatingSystem isMSDOSlike ifTrue:[
         self terminatePipeCommand.
-        self closeFileDescriptor.
+        self closeFile.
         ^ self.
     ].
 
     "terminate last under unix"
-    self closeFileDescriptor.
+    self closeFile.
     self terminatePipeCommand.
 !
 
@@ -580,42 +580,6 @@
 
 !PipeStream methodsFor:'private'!
 
-closeFileDescriptor
-    "alternative very low level close
-     This closes the underlying OS-fileDescriptor
-     - and will NOT write any buffered data to the stream.
-     You have been warned."
-
-    |action|
-
-%{
-#if !defined(transputer)
-    OBJ fp;
-    FILE *f;
-    extern close();
-    int retVal;
-
-    if ((fp = __INST(handle)) != nil) {
-        __INST(handle) = nil;
-        f = __FILEVal(fp);
-        if (@global(FileOpenTrace) == true) {
-            console_fprintf(stderr, "close [PipeStream] %"_lx_" fd=%d\n", (INT)f, fileno(f));
-        }
-#ifdef __win32__
-        do {
-            __threadErrno = 0;
-            retVal = __STX_C_NOINT_CALL1( "close", (void*)close, (void*)fileno(f) );
-        } while ((retVal < 0) && (__threadErrno == EINTR));
-#else
-        __BEGIN_INTERRUPTABLE__
-        close(fileno(f));
-        __END_INTERRUPTABLE__
-#endif
-    }
-#endif /* not transputer  */
-%}.
-!
-
 openPipeFor:aCommandString withMode:rwMode errorDisposition:errorDisposition inDirectory:aDirectory
     "open a pipe to the OS command in commandString;
      rwMode may be 'r' or 'w' or 'r+'.
@@ -697,15 +661,17 @@
         osProcess errorStream:errorDisposition.
     ]]]].
 
-    osProcess terminateActionBlock:[
-            "writing doesn't make sense - there is no reader any longer"
-            mode == #readwrite ifTrue:[
-                "... but allow to read the rest of the command's output"
-                self shutDownOutput.
-            ] ifFalse:[mode == #writeonly ifTrue:[
-                self closeFileDescriptor.
-            ]].
-       ].
+    mode ~~ #readonly ifTrue:[
+        osProcess terminateActionBlock:[
+                "writing doesn't make sense - there is no reader any longer"
+                mode == #readwrite ifTrue:[
+                    "... but allow to read the rest of the command's output"
+                    self shutDownOutput.
+                ] ifFalse:[mode == #writeonly ifTrue:[
+                    self closeFile.
+                ]].
+           ].
+    ].
 
     result := osProcess startProcess.