Win32OperatingSystem.st
changeset 14832 b010cb2aa396
parent 14783 93bf8545cbd5
child 14849 a0421ab568c4
child 18027 3621469cc5e8
--- a/Win32OperatingSystem.st	Mon Mar 04 16:16:51 2013 +0100
+++ b/Win32OperatingSystem.st	Mon Mar 04 16:17:19 2013 +0100
@@ -828,6 +828,7 @@
     "Modified: 7.1.1997 / 19:36:11 / stefan"
 ! !
 
+
 !Win32OperatingSystem class methodsFor:'OS signal constants'!
 
 sigABRT
@@ -6794,28 +6795,38 @@
 !
 
 terminateProcessGroup:processGroupHandleOrPid
-    "terminate a process group.
-     The processes should have a chance to do some cleanup.
-     WIN32:
-	 The processGroup is terminated by sending it a CTRL-C
-	 using GenerateConsoleCtrlEvent."
-
-    | pid list |
+    "terminate a process group (that is all subprocesses of a process)."
+
+    | pid list groupsToTerminate anyMore |
 
     list := self getAllProcesses.
     list size == 0 ifTrue:[^ self ].
 
     processGroupHandleOrPid isInteger ifTrue:[
-	pid := processGroupHandleOrPid
+        pid := processGroupHandleOrPid
     ] ifFalse:[
-	pid := processGroupHandleOrPid pid.
-    ].
-    list do:[:anOSProcess |
-	( anOSProcess parentPid == pid ) ifTrue:[
-	    self terminateProcess:( anOSProcess pid ).
-	].
-    ].
-
+        pid := processGroupHandleOrPid pid.
+    ].
+    groupsToTerminate := Set with:pid.
+    list := list asSet.
+
+    "/ Transcript show:'terminate group '; showCR:pid.
+    anyMore := true.
+    [anyMore] whileTrue:[
+        anyMore := false.
+        list do:[:anOSProcess |
+            |pid|
+
+            (groupsToTerminate includes:anOSProcess parentPid) ifTrue:[
+                pid := anOSProcess pid.
+                groupsToTerminate add:pid.
+                "/ Transcript show:'terminate '; showCR:pid.
+                self terminateProcess:( pid ).
+                list remove:anOSProcess.        
+                anyMore := true.
+            ].
+        ].
+    ].
 ! !
 
 !Win32OperatingSystem class methodsFor:'ipc support'!
@@ -16519,11 +16530,11 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.452 2013-02-18 15:08:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.453 2013-03-04 15:17:19 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.452 2013-02-18 15:08:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.453 2013-03-04 15:17:19 cg Exp $'
 !
 
 version_SVN