Daniel Berger
2006-May-07 03:52 UTC
[Win32utils-devel] Problem with the new version of win32-process
Hi all, Well, I''ve messed something up in the pure Ruby Process.fork method. If you run the test_fork_waitpid.rb file (in CVS), you''ll see this error: c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in `call'': can''t convert false into Integer (TypeError) from c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in `OpenProcess'' from C:/eclipse/workspace/win32-process/lib/win32/process.rb:67:in `waitpid2'' from C:/eclipse/workspace/win32-process/examples/test_fork.rb:46 Which means it''s returning false instead of the pid. Any ideas? Thanks, Dan PS - To run this you''ll need the latest windows-pr from CVS.
Heesob Park
2006-May-07 09:12 UTC
[Win32utils-devel] Problem with the new version of win32-process
Hi, 2006/5/7, Daniel Berger <djberg96 at gmail.com>:> Hi all, > > Well, I''ve messed something up in the pure Ruby Process.fork method. If > you run the test_fork_waitpid.rb file (in CVS), you''ll see this error: > > c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in `call'': can''t > convert false into Integer (TypeError) > from c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in > `OpenProcess'' > from > C:/eclipse/workspace/win32-process/lib/win32/process.rb:67:in `waitpid2'' > from C:/eclipse/workspace/win32-process/examples/test_fork.rb:46 > > Which means it''s returning false instead of the pid. Any ideas? >The error is due to static variable "i" is not ported correctly to ruby. Here is patch of process.rb : @@ -26,6 +26,7 @@ extend Windows::Console @child_pids = [] + @i = -1 # Waits for the given child process to exit and returns that pid. # @@ -425,14 +426,13 @@ # Kernel.fork method for Unix. # def fork - i = -1 last_arg = ARGV.last - # Look for the ''child#xxx'' tag - if last_arg =~ /child#\d+/ - i += 1 - num = last_arg.split(''#'').last.to_i - if num == i + # Look for the ''child#xxx'' tag + if last_arg =~ /child#\d+/ + @i += 1 + num = last_arg.split(''#'').last.to_i + if num == @i if block_given? status = 0 begin Regards, Park Heesob
Daniel Berger
2006-May-07 11:19 UTC
[Win32utils-devel] Problem with the new version of win32-process
Heesob Park wrote:> Hi, > > 2006/5/7, Daniel Berger <djberg96 at gmail.com>: >> Hi all, >> >> Well, I''ve messed something up in the pure Ruby Process.fork method. If >> you run the test_fork_waitpid.rb file (in CVS), you''ll see this error: >> >> c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in `call'': can''t >> convert false into Integer (TypeError) >> from c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in >> `OpenProcess'' >> from >> C:/eclipse/workspace/win32-process/lib/win32/process.rb:67:in `waitpid2'' >> from C:/eclipse/workspace/win32-process/examples/test_fork.rb:46 >> >> Which means it''s returning false instead of the pid. Any ideas? >> > The error is due to static variable "i" is not ported correctly to ruby.<snip> Aha! Many thanks! Dan