[Win32utils-devel] win32/process - small bug?

Daniel Berger djberg96 at gmail.com
Sun Nov 7 08:24:33 EST 2010


--- a/lib/win32/process.rb
+++ b/lib/win32/process.rb
@@ -559,14 +559,12 @@ module Process
           else
             if handle != 0
               thread_id = [0].pack('L')
-              dll       = 'kernel32'
-              eproc     = 'ExitProcess'
-
+              begin
               thread = CreateRemoteThread(
                 handle,
                 0,
                 0,
-                GetProcAddress(GetModuleHandle(dll), eproc),
+                  GetProcAddress(GetModuleHandle('kernel32'), 'ExitProcess'),
                 0,
                 0,
                 thread_id
@@ -579,9 +577,12 @@ module Process
               else
                 raise Error, get_last_error
               end
+              ensure
+                CloseHandle(thread) if thread
+              end
             else
               raise Error, get_last_error
-          end
+          end # case

           @child_pids.delete(pid)
         end

On Thu, Nov 4, 2010 at 8:52 AM, Daniel Berger <djberg96 at gmail.com> wrote:
> It might be a bit before I can get to this, so I thought I'd pass it on.
>
> Also, while I was stuck in the airport in Minneapolis, I decided that
> the getrlimit method should be refactored to remove the process from
> the job (if it wasn't already in one) after it's finished, if
> possible.
>
> Dan
>
>
> ---------- Forwarded message ----------
> From: Ben Nagy <ben.nagy.web at gmail.com>
> Date: Wed, Nov 3, 2010 at 11:53 PM
> Subject: win32/process - small bug?
> To: Daniel Berger <djberg96 at gmail.com>
>
>
> Hi,
>
> Very short note...
>
> I don't know how to do git pull requests and blah blah blah. I just
> fixed what I think is a bug in the win32/process code. You don't close
> the thread handle when you kill with signal 1. In my case I had a
> process monitor app that continued to think the PID was still alive,
> because the system continued to grant handles to the dead PID.
>
> Maybe the behaviour is intentional, I don't know. Anyway, hth.
>
> Cheers,
>
> ben
>


More information about the win32utils-devel mailing list