Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #2043 > unrolled thread

Re: how to refine the code to avoid using fork on windows?

Started byJeremy Bopp <jeremy@bopp.net>
First post2011-03-31 09:35 -0500
Last post2011-03-31 10:19 -0500
Articles 6 — 5 participants

Back to article view | Back to comp.lang.ruby

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: how to refine the code to avoid using fork on windows? Jeremy Bopp <jeremy@bopp.net> - 2011-03-31 09:35 -0500
    Re: how to refine the code to avoid using fork on windows? Ethan Huo <firewall888@hotmail.com> - 2011-03-31 09:49 -0500
      Re: how to refine the code to avoid using fork on windows? Michal Suchanek <hramrach@centrum.cz> - 2011-03-31 10:15 -0500
        Re: how to refine the code to avoid using fork on windows? Quintus <sutniuq@gmx.net> - 2011-03-31 12:14 -0500
          Re: how to refine the code to avoid using fork on windows? Ethan Huo <firewall888@hotmail.com> - 2011-03-31 21:50 -0500
      Re: how to refine the code to avoid using fork on windows? Nick Klauer <klauer@gmail.com> - 2011-03-31 10:19 -0500

#2043 — Re: how to refine the code to avoid using fork on windows?

FromJeremy Bopp <jeremy@bopp.net>
Date2011-03-31 09:35 -0500
SubjectRe: how to refine the code to avoid using fork on windows?
Message-ID<4D949129.3000005@bopp.net>
On 3/31/2011 09:18, Ethan Huo wrote:
> here is the thing, i need to move a previous ruby program from Linux to
> Windows, but Win doesn't support fork, how can i refine the code to make
> it work on Win?
> i googled a lot but still didn't get it, can anyone help me here?

Have you considered using Cygwin (http://cygwin.com) and the ruby
package it provides?  That will give you an emulated fork.  While Cygwin
is not a panacea for porting Unix applications to Windows, it may work
for you.

-Jeremy

[toc] | [next] | [standalone]


#2045

FromEthan Huo <firewall888@hotmail.com>
Date2011-03-31 09:49 -0500
Message-ID<1bbf34112cfccc125c45d6e350c9ed19@ruby-forum.com>
In reply to#2043
Jeremy Bopp wrote in post #990214:
> Have you considered using Cygwin (http://cygwin.com) and the ruby
> package it provides?  That will give you an emulated fork.  While Cygwin
> is not a panacea for porting Unix applications to Windows, it may work
> for you.
>
> -Jeremy

Hi, Jeremy, i knew cywin works for it, but cygwin has a memory limit for 
our usage, that's why we won't use cygwin any more.
what i need now it to move it into Mingw and get it work...
thanks for your quick reply, i appreciate it:)

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#2047

FromMichal Suchanek <hramrach@centrum.cz>
Date2011-03-31 10:15 -0500
Message-ID<AANLkTi=kk-r=xWahPkse1NK=n0rp9RQ8U+Tm4NNQuDZS@mail.gmail.com>
In reply to#2045
On 31 March 2011 16:49, Ethan Huo <firewall888@hotmail.com> wrote:
> Jeremy Bopp wrote in post #990214:
>> Have you considered using Cygwin (http://cygwin.com) and the ruby
>> package it provides?  That will give you an emulated fork.  While Cygwin
>> is not a panacea for porting Unix applications to Windows, it may work
>> for you.
>>
>> -Jeremy
>
> Hi, Jeremy, i knew cywin works for it, but cygwin has a memory limit for
> our usage, that's why we won't use cygwin any more.
> what i need now it to move it into Mingw and get it work...
> thanks for your quick reply, i appreciate it:)

You can also use the system() function.

Thread.new { system "dd", "if=/dev/zero", "of=/dev/null" }
=> #<Thread:0x7f81cb7337b0 sleep>

system "killall", "-USR1", "dd"
317912807+0 records in
317912807+0 records out
162771357184 bytes (163 GB) copied, 139.204 s, 1.2 GB/s
=> true

HTH

Michal

[toc] | [prev] | [next] | [standalone]


#2057

FromQuintus <sutniuq@gmx.net>
Date2011-03-31 12:14 -0500
Message-ID<4D94B69A.2040108@gmx.net>
In reply to#2047
Am 31.03.2011 17:15, schrieb Michal Suchanek:
> You can also use the system() function.
> 
> Thread.new { system "dd", "if=/dev/zero", "of=/dev/null" }
> => #<Thread:0x7f81cb7337b0 sleep>

A better way IMO is to use the #spawn method which calls the external
process and doesn't wait for it to complete. It immediately returns the
PID of the spawned process. Since Ruby 1.9 this works even on Windows.

Vale,
Marvin

[toc] | [prev] | [next] | [standalone]


#2081

FromEthan Huo <firewall888@hotmail.com>
Date2011-03-31 21:50 -0500
Message-ID<7714d94c2c57043b6d988d154b31522e@ruby-forum.com>
In reply to#2057
Marvin Gülker wrote in post #990237:
>
> A better way IMO is to use the #spawn method which calls the external
> process and doesn't wait for it to complete. It immediately returns the
> PID of the spawned process. Since Ruby 1.9 this works even on Windows.
>
> Vale,
> Marvin

Hi, Marvin
is #spawn's behavior just similar to fork+exec?
i am not very clear how to change the code to use #spawn instead, could 
you please give me some sample code to show how to using #spawn instead 
of fork+exec? thanks!

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#2049

FromNick Klauer <klauer@gmail.com>
Date2011-03-31 10:19 -0500
Message-ID<AANLkTinTWUH9B9AvgGUg+Jf134Zc74obny-aCWvNmsvR@mail.gmail.com>
In reply to#2045
[Note:  parts of this message were removed to make it a legal post.]

It might help to forward this on to the RubyInstaller group, since Luis
Lavena is maintaining the Ruby installer for Windows, he might know how to
handle it (or how to get DevKit to work with it):

http://groups.google.com/group/rubyinstaller




-Nick Klauer


On Thu, Mar 31, 2011 at 09:49, Ethan Huo <firewall888@hotmail.com> wrote:

> Jeremy Bopp wrote in post #990214:
> > Have you considered using Cygwin (http://cygwin.com) and the ruby
> > package it provides?  That will give you an emulated fork.  While Cygwin
> > is not a panacea for porting Unix applications to Windows, it may work
> > for you.
> >
> > -Jeremy
>
> Hi, Jeremy, i knew cywin works for it, but cygwin has a memory limit for
> our usage, that's why we won't use cygwin any more.
> what i need now it to move it into Mingw and get it work...
> thanks for your quick reply, i appreciate it:)
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web