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?

From Ethan Huo <firewall888@hotmail.com>
Newsgroups comp.lang.ruby
Subject how to refine the code to avoid using fork on windows?
Date 2011-03-31 09:18 -0500
Organization Service de news de lacave.net
Message-ID <21a67789ae6ce6e83dd836329b50863f@ruby-forum.com> (permalink)

Show all headers | 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