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


Groups > comp.lang.ruby > #2052

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail
From Ethan Huo <firewall888@hotmail.com>
Newsgroups comp.lang.ruby
Subject how to refine the code to avoid using fork on windows?
Date Thu, 31 Mar 2011 09:18:48 -0500
Organization Service de news de lacave.net
Lines 41
Message-ID <21a67789ae6ce6e83dd836329b50863f@ruby-forum.com> (permalink)
NNTP-Posting-Host bristol.highgroove.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace talisker.lacave.net 1301586513 77821 65.111.164.187 (31 Mar 2011 15:48:33 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Thu, 31 Mar 2011 15:48:33 +0000 (UTC)
X-Received-From This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway
X-Mail-Count 380689
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <21a67789ae6ce6e83dd836329b50863f@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:2052

Show key headers only | View raw


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?i paste
the code below:

def exec_cmd(cmd, toen=false, tmout=3600)
    return false if !$AveSubPID.nil?
    ret = fork
    if ret.nil? then
        exec "#{cmd}"
    end
    $AveSubPID = ret
    succ=true
    if (toen) then
        begin
            timeout(tmout) {
                Process.wait(ret)
                $AveSubPID = nil
                succ=$?.success?
                $AveErrno = $?.exitstatus
            }
        rescue Timeout::Error => e
            echo "(timeout) "
            kill_sub_process(ret)
            $AveSubPID = nil
            succ = false
            $AveErrno = $?.exitstatus
        end
    else
        Process.wait(ret)
        $AveSubPID = nil
        succ=$?.success?
        $AveErrno = $?.exitstatus
    end
    return succ
end

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

Back to comp.lang.ruby | Previous | NextNext in thread | Find similar | Unroll thread


Thread

how to refine the code to avoid using fork on windows? Ethan Huo <firewall888@hotmail.com> - 2011-03-31 09:18 -0500
  Re: how to refine the code to avoid using fork on windows? Tony Arcieri <tony.arcieri@medioh.com> - 2011-03-31 22:13 -0500
  Re: how to refine the code to avoid using fork on windows? Ethan Huo <firewall888@hotmail.com> - 2011-04-02 08:50 -0500

csiph-web