On Mon, 13 Sep 2004, Neubauer Christoph wrote: > Hi Ara ! > > Many thanks for the info below. > Unfortunately I'm not in the position to use extra packages > (Sorry, I should have mentioned this in the posting), > and my Ruby machine answers: > > ./fork_timeout.rb:7:in `fork': The fork() function is unimplemented on this > machine (NotImplementedError) > from ./fork_timeout.rb:7:in `timeout' > from ... > > Right at time I try to implement Robert's suggestion > of popen and parallel Threads, but I got stuck, somehow. perhaps something like this is what robert was suggesting, try some windows specific commands with it: ~ > cat popen_timeout.rb module PopenTimeout #{{{ class TimeoutError < StandardError; end def timeout n_sec, cmd #{{{ t = Thread.new(cmd) do |cmd| pipe = IO::popen(cmd) stdout = pipe.read pipe.close status = $?.exitstatus [stdout, status] end sleep n_sec case t.status when NilClass raise t.value when FalseClass return t.value else t.kill raise TimeoutError, "<#{ n_sec }>" end #}}} end module_function 'timeout' public 'timeout' #}}} end if $0 == __FILE__ stdout, status = PopenTimeout::timeout(2, 'sleep 1 && echo 42') puts stdout puts status stdout, status = PopenTimeout::timeout(1, 'sleep 2 && echo 42') end > Maybe I have to find a completely different solution, > e.g. passing control of time behaviour into called functionality. > So it will return at all means, either regularly or 'killing' itself. > > Many thanks (I could learn a lot) and best regards from Vienna > Chris > > PS: What (kind of) organization is "noaa.gov" ? national oceananic and atmouspheric administration, check out http://www.ngdc.noaa.gov/stp/stp.html to see what i do. we work with satelite imagery showing the nighttime lights of earth from space like http://dmsp.ngdc.noaa.gov/html/night_light_posters.html > PPS: I like 'your' Dogen quotation ! thanks - it's a constant reminder to myself to take things in stride. you are in germany? what's the programming market like there? we are thinking of moving! ;-) -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================