From: James Tucker Date: 2008-04-01T18:57:16+09:00 Subject: Re: sockets, windoze, and threads On 31 Mar 2008, at 22:06, ara.t.howard wrote: > > On Mar 31, 2008, at 12:50 PM, Luis Lavena wrote: >> >> Ara, didn't test the code yep, but you should move away from win32 as >> platform matcher for Windows, at least, if you plan your code work >> with the upcoming one-click installer: > > yeah this is just toy code at this point. still a valid point - > what would have us do to be rock solid Luis is will know better than I, but these are the two methods I've been using: Gem.win_platform? on RubyGems > 0.9.5 (or was it .4?) or RUBY_PLATFORM =~ /(cyg|ms)win|mingw/ Although it is worth noting that cygwin acts somewhat like unix (although there have been past warnings regarding the lack of security inherent in unix sockets under cygwin), so may need tailoring out for some platform specific codes. A more open regex would be: RUBY_PLATFORM =~ /win|min/ unless RUBY_PLATFORM =~ /darwin/ For these purposes, I might be tempted to do something like the following (which I know is verbose :( ) non_unix_platform = Gem.win_platform? rescue RUBY_PLATFORM =~ /mswin| mingw/ N.B. the rescue covers if rubygems is not loaded, as a fallback. As you will be able to fork and use unix sockets (for what they're worth) under cygwin. > has_fork = fork{ exit! } rescue nil > > ?? > >> http://blog.mmediasys.com/2008/03/29/progress-of-one-click-installer-rubyinstaller/ > this is really great - my thoughts on the topic are well documented > in the archives ;-) >> Will test it later and get back to you ;-) > so far it's rock solid - what this means is that i'll be able to > provide a cross platform open4 impl whereby client code can have > handles on pid, stdin, stdout, stderr for the child process in a > *thread safe* fashion - very cool. the sockets idea is from steve > shreeve btw... It may be possible to use named pipes? I will test this when I get to the office, > cheers. same to you :) james / raggi.