From: "ara.t.howard" Date: 2008-09-09T23:39:02+09:00 Subject: Re: Frustrated: System call timeouts On Sep 9, 2008, at 1:07 AM, Mikel Lindsaar wrote: > On Sun, Sep 7, 2008 at 12:42 AM, ara.t.howard > wrote: >> On Sep 6, 2008, at 3:43 AM, Mikel Lindsaar wrote: >>> Hello all, >>> I am having some (un)fun with timing out a database calls. >> try this: >> >> pid = Process.pid >> signaler = IO.popen "ruby -e'sleep #{ seconds }; >> Process.kill(:TERM.to_s, #{ pid }) rescue nil'" >> thread = Thread.current >> handler = Signal.trap('TERM'){ thread.raise Error, >> seconds.to_s } >> begin >> block.call >> ensure >> Process.kill 'TERM', signaler.pid rescue nil >> Signal.trap('TERM', handler) >> end > > Ara, thank you _so_ much for this. > > I would never have thought of spawning suicidal terminator ruby > processes to nuke my process :) But works well. > > i keep meaning to turn this into a library but have not. any other advice - besides the pid issue - that you encountered trying to make it live? cheers. a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama