[Win32utils-devel] Fwd: win32-process gem: waiting for process

Daniel Berger djberg96 at gmail.com
Tue Sep 24 18:07:11 UTC 2013


Thanks.

Could he use sleep 0.1 while Process.get_exitcode(info.process_id) ?

I'm also wondering in general if the builtin Process.spawn + Process.wait
works. I haven't tried it.

Regards,

Dan


On Tue, Sep 24, 2013 at 12:59 AM, Heesob Park <phasis at gmail.com> wrote:

> Hi,
>
> 2013/9/24 Daniel Berger <djberg96 at gmail.com>:
> >
> >
> > ---------- Forwarded message ----------
> > From: Praful (gmail) <praful007 at gmail.com>
> > Date: Mon, Sep 23, 2013 at 1:39 PM
> > Subject: win32-process gem: waiting for process
> > To: djberg96 at gmail.com
> >
> >
> > Hi
> >
> >
> >
> > I was trying your win32-process gem. Sorry for the silly question but
> how do
> > I wait for a created process to terminate after creating it? For
> example, if
> > I have
> >
> >
> >
> >                 info = Process.Create(…)
> >
> >                 WaitForSingleObject(info.process_handle, 9999)
> >
> >                 # do some work
> >
> >
> >
> > This does not work!
> >
> >
> >
> > I'm calling a function (that wraps Process.create) several times and am
> > finding the output garbled ie intermingled. I added a sleep after the
> call
> > and this worked but would rather wait for the created process to
> terminate.
> >
> >
> >
> > Also, is there a way of getting the exit code of the app being executed
> by
> > CreateProcess?
> >
> >
> Beware the default value of close_handles option is true.
>
> Here is a sample code:
>
> require 'win32/process'
>
>     info = Process.create(
>       :app_name         => 'ruby -e "sleep 5;exit(3)"',
>       :close_handles => false,
>     )
>
> if(Process::Functions::WaitForSingleObject(info.process_handle,-1)==0xFFFFFFFF)
>         raise SystemCallError, FFI.errno, "OpenProcess"
>     end
>     p Process.get_exitcode(info.process_id)
>
>
>
> Regards,
> Park Heesob
> _______________________________________________
> win32utils-devel mailing list
> win32utils-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/win32utils-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/win32utils-devel/attachments/20130924/8c85f9ad/attachment.html>


More information about the win32utils-devel mailing list