ruby.exe processes

63 views
Skip to first unread message

Shlomit Gazit

unread,
Mar 11, 2010, 4:27:17 PM3/11/10
to Watir General
I have lots of ruby.exe processes running after running watir test on
CI server.
Why there creating and how should I kill them after the test is
finished?

rakesh swain

unread,
Mar 15, 2010, 5:48:35 AM3/15/10
to watir-...@googlegroups.com
Hi, 

Execute the following. The process can be identified and terminated. 

require 'win32ole'
require 'win32/process'


           wmi = WIN32OLE.connect("winmgmts://")
           processes = wmi.ExecQuery("select * from Win32_process")
           for process in processes do
              if process.Name.include? "rubyw.exe" then
                 puts "Name: #{process.Name}"
                 #~ puts "Process ID: #{process.Pid}"
                 puts process.Terminate
                 puts "Finished Checking Processess and killing any process Leakage"
                elsif process.Name.include? "anyotherprocess.exe" then
                 #~ puts "Name: #{process.Name}"
                 #~ puts "Process ID: #{process.Pid}"
                 #~ puts process.Terminate
              end

Shlomit Gazit

unread,
Mar 15, 2010, 2:07:36 PM3/15/10
to Watir General
Hello,
Thank you.
Where would you recommend to put this code?

Shlomit Gazit

unread,
Mar 16, 2010, 7:41:47 PM3/16/10
to Watir General
Basically I have this method:

@pid = Process.create(
:app_name => 'ruby clicker.rb',
:creation_flags => Process::DETACHED_PROCESS
).process_id
at_exit{ Process.kill(9,@pid) }

which I think creating this process, but somehow at_exit is not
working.

rakesh swain

unread,
Mar 17, 2010, 2:49:24 AM3/17/10
to watir-...@googlegroups.com
Hi, 

This can be included as a function and you can call it in tear down. I use it as a common function and call the function in teardown of every class to clear all leaked threads. 

I guess the the process id is not getting identified in your code. Else you can change the logic for identifying the process id and use 

for process in processes do
              if process.Name.include? "rubyw.exe" then
                 #~ puts "Name: #{process.Name}"
                 puts "Process ID: #{process.Pid}"
              else 
              end
end

this process_id parameter can be passed in your at _exit - Process.Kill function  

See if this works

Thanks
Rakesh




Reply all
Reply to author
Forward
0 new messages