From: Christoph Neubauer Date: 2004-09-15T21:20:05+09:00 Subject: Re: How to Control Time Behaviour of System Call ? Hi Ara, Robert ! All attempts to control runtime behaviour of system call 'from outside' failed. Threads, Pipes, ... on ruby level everything was started/killed fine, but on system level, the activated command remainded alive until its natural end. So we decided to implement a different solution for our time control. We integrate a watchdog mechanism into one of our 'runtime libraries'. When a test case is started, a watchdog is started in background, too. When a testcase ends, it generates a normalized minute about its status (passed, failed, aborted, ...) and some other stuff. If a testcase is blocked and/or the watchdog finds out, that there is a timeout error, the watchdog generates a 'timeout' minute and exits immediately, this way aborting the testcase. So we get a uniform behaviour/interface of our testcases, regardless if they are started under supervision of a tester, or via the regression script. Many thanks for help, Chris "Ara.T.Howard" wrote in message news:Pine.LNX.4.60.0409130931040.12299@harp.ngdc.noaa.gov... > 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 > ============================================================================ ===