public
Description: ptrace wrapper for ruby
Homepage:
Clone URL: git://github.com/ko1/ruby-ptrace.git
ruby-ptrace / test.rb
100755 28 lines (23 sloc) 0.344 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'ptrace'
 
class PTrace
  def initialize
    pid = fork{
      yield
    }
    self.__attach__(pid)
    __set_pid__ pid
  end
end
 
ptrace = PTrace.new{
  p [$$, :hello]
  Process.kill :USR1, $$
}
 
while e = ptrace.wait
  case e
  when :SIGTRAP
    p [e, ptrace.getregs.orig_eax]
    ptrace.syscall
  else
    ptrace.syscall e
  end
end