From: J-Van Date: 2006-11-11T10:28:18+09:00 Subject: Re: win32/process question On 11/10/06, Park Heesob wrote: > >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 Thanks -- I'll try that. I'm not exactly sure what those functions do though. :-) Joe