AbstractOperatingSystem.st
changeset 23682 79c84500c6c1
parent 23637 8b59f50ab857
child 23749 d4940de82243
--- a/AbstractOperatingSystem.st	Thu Feb 07 14:26:23 2019 +0100
+++ b/AbstractOperatingSystem.st	Thu Feb 07 17:54:02 2019 +0100
@@ -709,40 +709,50 @@
     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
      This is typically used to present help-files, html documents, pdf documents etc.
      operationSymbol is one of:
-	open
-	edit
-	explore
+        open
+        edit
+        explore
      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
      if nil is passed in, the file's suffix is used to guess it.
     "
 
-    |openCommand mimeTypeString|
+    |openCommand mimeTypeString pid|
 
     mimeTypeString := mimeTypeStringArgOrNil.
 
     MIMETypes notNil ifTrue:[
-	mimeTypeString isNil ifTrue:[
-	    mimeTypeString := MIMETypes mimeTypeForFilename:aFilenameOrString.
-	].
-	mimeTypeString notNil ifTrue:[
-	    openCommand := MIMETypes defaultCommandTemplateToOpenMimeType:mimeTypeString.
-	].
+        mimeTypeString isNil ifTrue:[
+            mimeTypeString := MIMETypes mimeTypeForFilename:aFilenameOrString.
+        ].
+        mimeTypeString notNil ifTrue:[
+            openCommand := MIMETypes defaultCommandTemplateToOpenMimeType:mimeTypeString.
+        ].
     ].
     openCommand notEmptyOrNil ifTrue:[
-	(openCommand includesSubString:'%1') ifTrue:[
-	    openCommand := openCommand bindWith:aFilenameOrString asString.
-	] ifFalse:[
-	    openCommand := openCommand, ' "', aFilenameOrString asString, '"'.
-	].
-
-	(self
-		startProcess:openCommand
-		inputFrom:nil outputTo:nil
-		errorTo:nil auxFrom:nil
-		environment:nil inDirectory:directoryStringOrFilenameOrNil) notNil
-	ifTrue:[
-	    ^ self.
-	].
+        (openCommand includesSubString:'%1') ifTrue:[
+            openCommand := openCommand bindWith:aFilenameOrString asString.
+        ] ifFalse:[
+            openCommand := openCommand, ' "', aFilenameOrString asString, '"'.
+        ].
+
+        pid := self
+                startProcess:openCommand
+                inputFrom:nil outputTo:nil
+                errorTo:nil auxFrom:nil
+                environment:nil inDirectory:directoryStringOrFilenameOrNil
+                newPgrp:true showWindow:nil.
+        pid notNil ifTrue:[
+            UserPreferences current logExecutedOSCommands ifTrue:[
+                Transcript showCR:(('OS process for: %1 (pid=%2)' bindWith:openCommand with:pid) 
+                                        withColor:Color brown).  
+            ].
+            ^ self.
+        ].
+        UserPreferences current logExecutedOSCommands ifTrue:[
+            Transcript showCR:(('failed to start OS process for: %1' bindWith:openCommand) 
+                                    withColor:Color brown).  
+        ].
+        self halt.
     ].
     ExecutionError raiseErrorString:'execution of command failed: ', openCommand.
 
@@ -755,6 +765,7 @@
 
     "Created: / 29-10-2010 / 12:16:38 / cg"
     "Modified: / 05-02-2011 / 16:13:42 / cg"
+    "Modified: / 07-02-2019 / 17:06:07 / Claus Gittinger"
 !
 
 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil
@@ -762,20 +773,20 @@
     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
      This is typically used to present help-files, html documents, pdf documents etc.
      operationSymbol is one of:
-	open
-	edit
-	explore
+        open
+        edit
+        explore
      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
      if nil is passed in, the file's suffix is used to guess it.
     "
 
     [
-	^ self
-	    openApplicationForDocument:aFilenameOrString
-	    operation:operationSymbol mimeType:mimeTypeStringArgOrNil
-	    inDirectory:directoryStringOrFilenameOrNil.
+        ^ self
+            openApplicationForDocument:aFilenameOrString
+            operation:operationSymbol mimeType:mimeTypeStringArgOrNil
+            inDirectory:directoryStringOrFilenameOrNil.
     ] on:ExecutionError do:[:ex|
-	exceptionBlock value.
+        exceptionBlock value.
     ].
 ! !