[Title] Fixed to support "cancel" on windows OS
authordonghee yang <donghee.yang@samsung.com>
Tue, 25 Sep 2012 01:22:18 +0000 (10:22 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Tue, 25 Sep 2012 01:22:18 +0000 (10:22 +0900)
src/common/utils.rb

index b3d1a6be03351b16f30b058b4e74386ca29f3af4..46a4d6eacb3ff67c54b566fe6a5dba45e9631e9c 100644 (file)
@@ -539,7 +539,19 @@ class Utils
 
     def Utils.descendant_processes(base=Process.pid)
         descendants = Hash.new{|ht,k| ht[k]=[k]}
-        Hash[*`ps -eo pid,ppid`.scan(/\d+/).map{|x|x.to_i}].each{|pid,ppid|
+
+               # generate pid => ppid hash
+               # NOTE. MinGW does not support "-o" option and has different output format
+               rel_hash = nil
+               os_category = get_os_category(HOST_OS)
+               if os_category != "windows" then        
+               rel_hash = Hash[*`ps -eo pid,ppid`.scan(/\d+/).map{|x| x.to_i}]
+               else
+                       rel_hash = Hash[*`ps -e`.scan(/^[\t\s]*(\d+)[\t\s]+(\d+)/).flatten.map{|x| x.to_i}]
+               end
+
+               # make pid => all descendent processes
+               rel_hash.each{|pid,ppid|
                 descendants[ppid] << descendants[pid]
         }       
         return descendants[base].flatten - [base]