Win32OperatingSystem.st
changeset 23636 b9e5840e2c22
parent 23534 ec2221eaada0
child 23638 37512eec04c2
--- a/Win32OperatingSystem.st	Tue Jan 22 17:17:23 2019 +0100
+++ b/Win32OperatingSystem.st	Tue Jan 22 17:19:10 2019 +0100
@@ -3855,72 +3855,77 @@
 !
 
 exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork
-	newPgrp:newPgrp inDirectory:aDirectory
-	showWindow:showWindowBooleanOrNil
+        newPgrp:newPgrp inDirectory:aDirectory
+        showWindow:showWindowBooleanOrNil
 
     "Internal lowLevel entry for combined fork & exec for WIN32
 
      If fork is false (chain a command):
-	 execute the OS command specified by the argument, aCommandPath, with
-	 arguments in argArray (no arguments, if nil).
-	 If successful, this method does not return and smalltalk is gone.
-	 If not successful, it does return.
-	 Normal use is with forkForCommand.
+         execute the OS command specified by the argument, aCommandPath, with
+         arguments in argArray (no arguments, if nil).
+         If successful, this method does not return and smalltalk is gone.
+         If not successful, it does return.
+         Normal use is with forkForCommand.
 
      If fork is true (subprocess command execution):
-	fork a child to do the above.
-	The Win32ProcessHandle of the child process is returned; nil if the fork failed.
+        fork a child to do the above.
+        The Win32ProcessHandle of the child process is returned; nil if the fork failed.
 
      fdArray contains the filedescriptors, to be used for the child (if fork is true).
-	fdArray[1] = 15 -> use fd 15 as stdin.
-	If an element of the array is set to nil, the corresponding filedescriptor
-	will be closed for the child.
-	fdArray[0] == StdIn for child
-	fdArray[1] == StdOut for child
-	fdArray[2] == StdErr for child
+        fdArray[1] = 15 -> use fd 15 as stdin.
+        If an element of the array is set to nil, the corresponding filedescriptor
+        will be closed for the child.
+        fdArray[0] == StdIn for child
+        fdArray[1] == StdOut for child
+        fdArray[2] == StdErr for child
 
      NOTE that in WIN32 the fds are HANDLES.
 
      If newPgrp is true, the subprocess will be established in a new process group.
-	The processgroup will be equal to id.
-	newPgrp is not used on WIN32 and VMS systems.
+        The processgroup will be equal to id.
+        newPgrp is not used on WIN32 and VMS systems.
 
      showWindowOrBoolean may be:
-	true  - a window is shown on start of the command
-	false - the command window is hidden
-	nil   - the nCmdShown parameter of the commans's winmain function determins,
-		if a window is shown.
-	#default
-	      - same as nil
-    "
-
-    |dirPath rslt|
+        true  - a window is shown on start of the command
+        false - the command window is hidden
+        nil   - the nCmdShown parameter of the commans's winmain function determins,
+                if a window is shown.
+        #default
+              - same as nil
+    "
+
+    |dirPath handle|
 
     aDirectory notNil ifTrue:[
-	dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory.
-	(dirPath endsWith:':') ifTrue:[
-	    dirPath := dirPath , '\'.
-	].
-    ].
-
-    rslt := self
-	primExec:aCommandPath
-	commandLine:argString
-	environment:environment
-	fileDescriptors:fdArray
-	fork:doFork
-	newPgrp:newPgrp
-	inPath:dirPath
-	createFlags:nil
-	inheritHandles:true
-	showWindow:showWindowBooleanOrNil.
+        dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory.
+        (dirPath endsWith:':') ifTrue:[
+            dirPath := dirPath , '\'.
+        ].
+    ].
+
+    handle := self
+        primExec:aCommandPath
+        commandLine:argString
+        environment:environment
+        fileDescriptors:fdArray
+        fork:doFork
+        newPgrp:newPgrp
+        inPath:dirPath
+        createFlags:nil
+        inheritHandles:true
+        showWindow:showWindowBooleanOrNil.
+
+    handle notNil ifTrue:[
+        handle registerForFinalization.
+    ].
 
 "/ 'created ' print. cmdLine print. ' -> ' print. rslt printCR.
-    ^ rslt
+    ^ handle
 
     "Modified: / 31-01-1998 / 10:54:24 / md"
     "Modified: / 15-05-1999 / 18:07:51 / cg"
     "Modified (comment): / 18-10-2016 / 16:00:26 / cg"
+    "Modified: / 22-01-2019 / 16:35:10 / Stefan Vogel"
 !
 
 getStatusOfProcess:aProcessId
@@ -18872,6 +18877,13 @@
     ^ super printString, ' pid:', pid printString.
 ! !
 
+!Win32OperatingSystem::Win32ProcessHandle methodsFor:'release'!
+
+close
+    self closeHandle.
+    self unregisterForFinalization.
+! !
+
 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'opening'!
 
 open:portName baudRate:baudRate stopBitsType:stopBitsType