[Win32utils-devel] Fw: re. win32-process

Heesob Park phasis at gmail.com
Tue Nov 21 03:16:40 EST 2006


Hi,

2006/11/21, Daniel Berger <djberg96 at yahoo.com>:
>
> Hi all,
>
> Any ideas for the question below?  I know how to do this in theory - make
> the 'inherit' flag true, and set the 'stdout' and 'stderr' startf_flags hash
> options to something in the startup_info hash, but I wasn't sure how to do
> this in practice.
>
> It would be nice if the answer could be something like this:
>
> require 'win32/process'
>
> app_name = 'c:\ruby\bin\ruby "' + Dir.pwd + '/test.rb"'
> my_out = $stdout.clone
> my_err = $stderr.clone
> my_out.reopen('NUL')
> my_err.reopen('NUL')
>
> Process.create(
>   :app_name => app_name,
>   :inherit  => true,
>   :creation_flags => Process::DETACHED_PROCESS,
>   :startup_info => {
>      :startf_flags => Process::STARTF_USESTDHANDLES,
>      :stdout => my_out,
>      :stderr => my_err
>   }
> )
>
> I think it would be neat if you could pass IO objects (or perhaps a
> fileno) to :stdout, :stderr, and :stdin directly.  Any ideas on how to do
> that?
>
> Thanks,
>
> Dan


Use _get_osfhandle function like this:

  :stdout => _get_osfhandle(my_out.to_i),
  :stderr => _get_osfhandle(my_err.to_i),

Regards,

Park Heesob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20061121/fb330ea0/attachment.html 


More information about the win32utils-devel mailing list