OSProcess.st
changeset 22987 3ee91cc9e2d0
parent 22986 6574facad5bf
child 22994 fdfec343e2de
--- a/OSProcess.st	Tue May 22 12:43:11 2018 +0200
+++ b/OSProcess.st	Tue May 22 12:58:45 2018 +0200
@@ -5,19 +5,19 @@
 "{ NameSpace: Smalltalk }"
 
 Object subclass:#OSProcess
-	instanceVariableNames:'pid command environment directory inStream outStream errorStream
-		auxStream showWindow lineWise newPgrp exitStatus finishSema
-		shufflerProcesses streamsToClose terminateActionBlock'
-	classVariableNames:''
-	poolDictionaries:''
-	category:'System-Support'
+        instanceVariableNames:'pid command environment directory inStream outStream errorStream
+                auxStream showWindow lineWise newPgrp exitStatus finishSema
+                shufflerProcesses streamsToClose terminateActionBlock'
+        classVariableNames:''
+        poolDictionaries:''
+        category:'System-Support'
 !
 
 OSProcess subclass:#RemoteOSProcess
-	instanceVariableNames:'host'
-	classVariableNames:'MethodPerHost'
-	poolDictionaries:''
-	privateIn:OSProcess
+        instanceVariableNames:'host'
+        classVariableNames:'MethodPerHost'
+        poolDictionaries:''
+        privateIn:OSProcess
 !
 
 !OSProcess class methodsFor:'documentation'!
@@ -628,9 +628,12 @@
 
 startCommand
     "the 'real' command to be executed.
-     Redefined for remote processes (eg. to construct a remote command string)"
+     Redefined for remote processes (eg. to construct a remote command string).
+     Command may be both an Array or a String"
     
     ^ command
+
+    "Modified (comment): / 22-05-2018 / 12:37:38 / Stefan Vogel"
 ! !
 
 !OSProcess methodsFor:'queries'!
@@ -685,11 +688,15 @@
 !
 
 startProcess
-    "If there are non-external streams, setup transfer (shuffler) processes
+    "Start the command asynchronously (i.e. don't wait until is has finished).
+     If there are non-external streams, setup transfer (shuffler) processes
      to transfer data from a pipe to the internal stream.
-     Start the command.
-     Answer true if the command could be started, false if not.
-     Return immediately (do not wait until the command is finished)." 
+
+     Answer true if the command could started succesfully, false if not.
+
+     NOTE: under normal circumstances, even if the command cannot be found,
+           the exit fom the command interpreter/shell is done some time later
+           So you have to check later or set #terminateActionBlock: and check there."
 
     |externalInStream externalAuxStream externalErrorStream externalOutStream callingProcess|
 
@@ -711,7 +718,7 @@
 
     "/ UserPreferences current logExecutedOSCommands:true
     UserPreferences current logExecutedOSCommands ifTrue:[
-        Transcript showCR:('OS command: ',self startCommand printString).  
+        Transcript showCR:('OS command: ', self startCommand printString).  
     ].
 
     callingProcess := Processor activeProcess.
@@ -770,8 +777,17 @@
         ^ false.
     ].
 
+    (exitStatus notNil and:[exitStatus isError]) ifTrue:[
+        "if we get an early exit status, we can return an error.
+         NOTE: under normal circumstances, the command exits some time later -
+               even if the command cannot be found. So you have to check the exitStatus later
+               or set #terminateActionBlock:"
+        ^ false.
+    ].
+
     ^ true.
 
+    "Modified (comment): / 22-05-2018 / 12:54:26 / Stefan Vogel"
     "Modified: / 22-05-2018 / 12:39:18 / Claus Gittinger"
 ! !