From: Park Heesob Date: 2006-11-11T10:07:07+09:00 Subject: Re: win32/process question >From: J-Van >Reply-To: ruby-talk@ruby-lang.org >To: ruby-talk@ruby-lang.org (ruby-talk ML) >Subject: Re: win32/process question >Date: Sat, 11 Nov 2006 09:29:10 +0900 > .... > >If I use Process.waitpid in a thread, all the other threads seem to >block until the process that I'm waiting for stops. > >I'm writing a program that runs on a windows machine that listens for >requests to start and kill programs. It needs to be able to run and >kill multiple programs and needs to be able to monitor the programs >that it has started to make sure that they are still running. If >Process.waitpid makes the whole Ruby process hang, that's no good. > >Joe > If you don't want blocking, try WaitForSingleObect like this: require 'win32/process' include Windows::Handle include Windows::Synchronize info = Process.create :app_name=>'notepad' begin i = WaitForSingleObject(info.process_handle,10) if i==WAIT_OBJECT_0 CloseHandle(info.process_handle) CloseHandle(info.thread_handle) end # do something end while i==WAIT_TIMEOUT Regards, Park Heesob _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/