#executeComand:inputFrom:....
authorStefan Vogel <sv@exept.de>
Wed, 10 Jul 2002 13:55:43 +0200
changeset 6618 a5720cd8006e
parent 6617 e582d421c0b7
child 6619 23b5cbfd23dc
#executeComand:inputFrom:.... /dev/null descriptor handling
AbstractOperatingSystem.st
--- a/AbstractOperatingSystem.st	Wed Jul 10 13:46:34 2002 +0200
+++ b/AbstractOperatingSystem.st	Wed Jul 10 13:55:43 2002 +0200
@@ -1153,49 +1153,43 @@
      Nil stream args will execute the command connected to ST/X's input, output or
      error resp. - i.e. i/o will be from/to the xterminal"
 
-    |pid exitStatus sema pIn pOut pErr externalInStream externalOutStream externalErrStream inputShufflerProcess outputShufflerProcess errorShufflerProcess inStreamToClose outStreamToClose errStreamToClose terminateLock stopShufflers|
+    |pid exitStatus sema pIn pOut pErr externalInStream externalOutStream externalErrStream 
+     inputShufflerProcess outputShufflerProcess errorShufflerProcess stopShufflers
+     inStreamToClose outStreamToClose errStreamToClose terminateLock|
 
     terminateLock := Semaphore forMutualExclusion.
-    (externalInStream := anInStream) notNil ifTrue:[
-        anInStream isExternalStream ifFalse:[
-            pIn := ExternalStream makePipe.
-            inStreamToClose := externalInStream := pIn at:1.
-
-            "/ start a reader process, shuffling data from the given
-            "/ inStream to the pipe (which is connected to the commands input)
-            inputShufflerProcess := [
-                        |s|
-
-                        s := pIn at:2.   "/ thats where the shuffler writes to
-                        [
-                            [s atEnd] whileFalse:[
-                                self 
-                                    shuffleFrom:anInStream
-                                    to:s
-                                    lineWise:lineWise.
-                                s flush
-                            ]
-                        ] ensure:[
-                            s close
+    ((externalInStream := anInStream) notNil 
+     and:[externalInStream isExternalStream not]) ifTrue:[
+        pIn := ExternalStream makePipe.
+        inStreamToClose := externalInStream := pIn at:1.
+
+        "/ start a reader process, shuffling data from the given
+        "/ inStream to the pipe (which is connected to the commands input)
+        inputShufflerProcess := [
+                    |s|
+
+                    s := pIn at:2.   "/ thats where the shuffler writes to
+                    [
+                        [s atEnd] whileFalse:[
+                            self 
+                                shuffleFrom:anInStream
+                                to:s
+                                lineWise:lineWise.
+                            s flush
                         ]
-                    ] forkNamed:'cmd input shuffler'.
-
-        ]
-    ] ifFalse:[
-        inStreamToClose := externalInStream := '/dev/null' asFilename readStream
+                    ] ensure:[
+                        s close
+                    ]
+                ] forkNamed:'cmd input shuffler'.
     ].
-    (externalOutStream := anOutStream) notNil ifTrue:[
-        anOutStream isExternalStream ifFalse:[
-            pOut := ExternalStream makePipe.
-            outStreamToClose := externalOutStream := pOut at:2.
-            outputShufflerProcess := 
-                        [
-                            self shuffleAllFrom:(pOut at:1) to:anOutStream lineWise:lineWise lockWith:terminateLock.    
-                        ] forkNamed:'cmd output shuffler'.
-        ]
-    ] ifFalse:[
-        outStreamToClose := externalOutStream := '/dev/null' asFilename 
-                            readStream
+    ((externalOutStream := anOutStream) notNil 
+     and:[externalOutStream isExternalStream not]) ifTrue:[
+        pOut := ExternalStream makePipe.
+        outStreamToClose := externalOutStream := pOut at:2.
+        outputShufflerProcess := 
+                    [
+                        self shuffleAllFrom:(pOut at:1) to:anOutStream lineWise:lineWise lockWith:terminateLock.    
+                    ] forkNamed:'cmd output shuffler'.
     ].
     (externalErrStream := anErrStream) notNil ifTrue:[
         anErrStream == anOutStream ifTrue:[
@@ -1210,13 +1204,6 @@
                         ] forkNamed:'cmd err-output shuffler'.
             ]
         ]
-    ] ifFalse:[
-        outStreamToClose isNil ifTrue:[
-            externalErrStream := errStreamToClose := '/dev/null' asFilename 
-                                readStream
-        ] ifFalse:[
-            externalErrStream := externalOutStream
-        ]
     ].
     sema := Semaphore new name:'OS command wait'.
     pid := Processor 
@@ -4424,6 +4411,6 @@
 !AbstractOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.70 2002-07-10 10:20:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.71 2002-07-10 11:55:43 stefan Exp $'
 ! !
 AbstractOperatingSystem initialize!