From: Joel VanderWerf Date: 2006-11-16T10:13:10+09:00 Subject: Re: thread dump? Eric Hodel wrote: > On Oct 22, 2006, at 12:12 PM, Joel VanderWerf wrote: >> cs5b@yahoo.com wrote: >>> Hi there, I have a process that seems to be stuck somewhere. Is there >>> the possibility of doing a thread dump to show where it is hanging on? >>> Cheers - >>> Christian >> >> Not in general, without a Thread#backtrace method. I've asked for it... >> >> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/159482 >> >> As noted in that post, you can destructively find out where the thread >> is by calling #raise on it. Just make sure the thread has an exception >> handler somewhere to print out the exception and backtrace. > > $ ruby -e 't = Thread.start do sleep end; t.raise "hi"; t.value' > -e:1: hi (RuntimeError) > from -e:1:in `value' > from -e:1 That doesn't tell you what line of code the thread is sleeping on, only what lines of code #raise and #value are called on. You lose the whole backtrace, in fact. $ cat th.rb t = Thread.start do sleep end t.raise "hi" t.value $ ruby th.rb th.rb:5: hi (RuntimeError) from th.rb:6:in `value' from th.rb:6 -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407