tags:

views:

54

answers:

2

Hi,

I have a long running ruby script, in Linux, which has some interesting data stored in a hash table. The program does not have any persistence mechanism and I am interested in copying the data from it's hash table. Is there any way to copy data from the memory of a running ruby script?

raj

+6  A: 

It's not for the faint of heart, but there's a tool called Hijack that can give you a live irb prompt to a running ruby process. RubyInside has a very brief rundown and example of how to use it.

John Hyland
Thanks, I will look into it.
Rajkumar S
# /var/lib/gems/1.8/gems/ileitch-hijack-0.1.9/bin/hijack 828 => Hijacking...It's not moving forward from here :(
Rajkumar S
A: 

It would be very easy to add a signal handler that responds by dumping a serialized version of your hashtable.

See Signal.trap.

Jonathan Feinberg
the program is already running so changing code is not possible
Rajkumar S