From: Tony Arcieri Date: 2011-04-01T12:13:51+09:00 Subject: Re: how to refine the code to avoid using fork on windows? --0016e6d64527531b61049fd2c641 Content-Type: text/plain; charset=ISO-8859-1 Check out the childprocess gem: https://github.com/jarib/childprocess On Thu, Mar 31, 2011 at 8:18 AM, 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?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/. > > -- Tony Arcieri Medioh! Kudelski --0016e6d64527531b61049fd2c641--