[Win32utils-devel] [ win32utils-Bugs-21838 ] cannot kill the forked process from main process

noreply at rubyforge.org noreply at rubyforge.org
Fri Sep 5 17:37:08 EDT 2008


Bugs item #21838, was opened at 2008-09-05 17:37
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=411&aid=21838&group_id=85

Category: win32-process
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Nobody (None)
Assigned to: Nobody (None)
Summary: cannot kill the forked process from main process

Initial Comment:
Hi there,

I have the problem to kill the forked process. The test code is listed below:

require 'rubygems'
require 'win32/process.rb'

begin
  
  pid = Process.fork do 

    2.times do
      sleep 10
      puts "output from process #{Process.pid}"
    end
  end
  
  puts ARGV.inspect
  if !(ARGV.last =~ /child/)
    puts "start parent process"
    sleep 11
    Process.kill('INT', [pid]) 
    
    1.times do
       puts "output from parent process"
       sleep 10
    end   
  end

rescue Exception => err
  puts "%s, %s"% [ err.inspect, err.backtrace]
end

when I run this test code, I always get the exception. Here is the test log:

C:\myworkspace\SSMSProject\Source\ruby>ruby Noname3.rb
start parent process
output from process 5680
#<TypeError: can't convert Array into Integer>, (eval):3:in `call'(eval):3:in `O
penProcess'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win32/process.
rb:143:in `kill'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win32/pro
cess.rb:132:in `each'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win3
2/process.rb:132:in `kill'Noname3.rb:19

C:\myworkspace\SSMSProject\Source\ruby>output from process 5680
start parent process
#<TypeError: can't convert Array into Integer>, (eval):3:in `call'(eval):3:in `O
penProcess'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win32/process.
rb:143:in `kill'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win32/pro
cess.rb:132:in `each'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win3
2/process.rb:132:in `kill'C:/myworkspace/SSMSProject/Source/ruby/Noname3.rb:19

C:\myworkspace\SSMSProject\Source\ruby>ruby Noname3.rb
[]
start parent process
output from process 532
#<TypeError: can't convert Array into Integer>, (eval):3:in `call'(eval):3:in `O
penProcess'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win32/process.
rb:143:in `kill'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win32/pro
cess.rb:132:in `each'C:/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.3/lib/win3
2/process.rb:132:in `kill'Noname3.rb:20

C:\myworkspace\SSMSProject\Source\ruby>output from process 532
["child#0"]

Do I miss something to make Process.kill work? Any help would be much appreciated. Thanks in advance!

Qi


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=411&aid=21838&group_id=85


More information about the win32utils-devel mailing list