OSProcess.st
changeset 25323 72863286fa82
parent 25302 3ab39726c023
--- a/OSProcess.st	Fri Mar 06 15:06:44 2020 +0100
+++ b/OSProcess.st	Fri Mar 06 15:39:32 2020 +0100
@@ -794,28 +794,22 @@
     pidHandle close.
 !
 
-setupShufflerForInput:aStream
-    "if aStream is an internal Stream, set up a pipe for the command input.
+setupShufflerForInput:aReadStream
+    "if aReadStream is an internal Stream, set up a pipe for the command input.
      Start a process that shuffles the data from the internal stream into the pipe
      (and into the command's input).
      Return the ExternalStream that should be passed to the OS process."
 
     |pipe externalStream shuffledStream shufflerProcess|
 
-    (aStream isNil or:[aStream isExternalStream]) ifTrue:[
-        ^ aStream.
+    (aReadStream isNil or:[aReadStream isExternalStream]) ifTrue:[
+        ^ aReadStream.
     ].
 
     pipe := PipeStream makePipe.
     externalStream := pipe at:1.
     shuffledStream := pipe at:2.
     shuffledStream setCommandString:('Stdin of: ', command printString).
-    lineWise ifFalse:[
-        shuffledStream blocking:false.
-    ].
-    aStream isBinary ifTrue:[
-        shuffledStream binary.
-    ].
 
     "/ start a reader process, shuffling data from the given
     "/ inStream to the pipe (which is connected to the commands input)
@@ -824,17 +818,21 @@
             [
                 lineWise ifTrue:[
                     "shuffle until end-of-input"
-                    [aStream atEnd] whileFalse:[
+                    [aReadStream atEnd] whileFalse:[
                         |data|
 
-                        data := aStream nextLine.
+                        data := aReadStream nextLine.
                         data notNil ifTrue:[
-                            shuffledStream nextPutLine:data.
-                            shuffledStream flush.
+                            shuffledStream nextPutLine:data; flush.
                         ].
                     ].
                 ] ifFalse:[
-                    aStream copyToEndInto:shuffledStream.
+                    aReadStream isBinary ifTrue:[
+                        shuffledStream binary.
+                    ].
+                    "#copyToEndInto: is non-blocking because is uses 
+                     NonPositionableExternalStream >> #nextPutBytes:from:startingAt:"
+                    aReadStream copyToEndInto:shuffledStream.
                 ].
             ] on:WriteError do:[:ex|
                 "ignore"