 |
Forums |
Admin Discussion Forums: help Start New Thread
By: Qi Lu
RE: Problem with Process.kill and SIGINT [ reply ] 2008-09-17 17:52
|
Like I mentioned in my last reply, I modified the fork function to fit my own need. I just simply copy the process.rb file to myprocess.rb file and change my own file. This is not a good solution since I need to update my code when process.rb is changed. I have reported the bug of missing to include 'Thread' to RubyForge. Hopefully they will fix it soon.
|
By: Qi Lu
RE: Problem with Process.kill and SIGINT [ reply ] 2008-09-11 13:38
|
Have you tried to use signal 4-8? but when you use signal 4-8, you need to fix a ruby bug in process.rb by adding
require 'windows/thread'
....
include Windows::Thread
......
extend Windows::Thread
....
It works in my project.
|
By: Scott Bourdeau
RE: Problem with Process.kill and SIGINT [ reply ] 2008-08-21 10:25
|
Daniel,
Thanks for the suggestion. I've tried most combinations of creation flags with both signals 2 and 1. 1 seems to always kill the process, but the processes output never gets written to disk. 2 does not kill the process and the processes output still does not get written to disk. I also tried switching up the process_inherit and thread_inherit flags to no avail.
I've tried calling rcov.bat (which just calls rcov) directly, and rcov directly as well, and the behavior doesn't seem to change. I am stumped at this point.
Any more suggestions?
Scott
|
By: Daniel Berger
RE: Problem with Process.kill and SIGINT [ reply ] 2008-08-20 15:11
|
Ah, I see the issue now I think. The win32-process library redefines Process.kill. It interprets a SIGINT as signal 2, which equates to a CTRL_C_EVENT. That won't work unless you've started the process with the CREATE_NEW_PROCESS_GROUP flag. The SIGKILL is interpreted as signal 9, which is the brutal but effective TerminateProcess() approach.
I recommend using signal 1.
Regards,
Dan
|
By: Scott Bourdeau
Problem with Process.kill and SIGINT [ reply ] 2008-08-20 09:46
|
Trying to use win32-process on Windows 2003 Server to kick off a process from a rake file, then ultimately kill that process with a SIGINT. Seems the process never gets the SIGINT. If I use SIGKILL, it works fine. Here's a code snippet. Any ideas?
The ultimate problem I have below is since the rcov process never gets the SIGINT signal, it never writes its output (HTML) files to disk. If I run the same process from the command line, and manually Ctrl-C it, it works fine.
Code snippet:
require 'win32/process'
namespace :watir do
desc 'Measures test coverage of Watir scripts'
task :coverage do
build_artifacts=ENV['CC_BUILD_ARTIFACTS']
covdir=(build_artifacts.nil? ? "coverage" : "#{build_artifacts}/WatirCoverage")
mkdir_p covdir unless File.directory? covdir if covdir
=begin
@mongrel_pid = Process.create(
:app_name =>"c:\\ruby\\bin\\rcov script/server -o #{covdir} --rails -Ilib -- -e test",
:creation_flags => Process::CREATE_DETACHED_PROCESS,
:process_inherit => false,
:thread_inherit => true,
:cwd => "C:\\cruise\\projects\\trunk\\work"
).process_id
=end
puts @mongrel_pid.to_s
sleep(8) # wait for server to startup
begin
Rake::Task["test:watir"].invoke
rescue SystemExit; end
puts @mongrel_pid.to_s
Process.kill("INT", @mongrel_pid)
Process.waitpid(@mongrel_pid)
end
------------
I have tried this code with various values of creation flags along with no Process.waitxxx at all or just Process.wait.
Thanks for any help you can provide.
Scott
|
|
 |