[Win32utils-devel] Problem with the new version of win32-process

Heesob Park phasis at gmail.com
Sun May 7 05:12:53 EDT 2006


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



More information about the win32utils-devel mailing list